Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'Owin.IAppBuilder' does not contain a definition for 'MapSignalR'

Error

'Owin.IAppBuilder' does not contain a definition for 'MapSignalR' and no extension method 'MapSignalR' accepting a first argument of type 'Owin.IAppBuilder' could be found (are you missing a using directive or an assembly reference?)

Code

using Microsoft.Owin;
using Owin;

[assembly: OwinStartup(typeof(SignalRChat.Startup))]
namespace SignalRChat
{
    public class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            // Any connection or hub wire up and configuration should go here
            app.MapSignalR();
        }
    }
}  

Any help would be greatly appreciated...

Update

signalR version 2.0.3
Microsoft Owin version 2.0.2
Owin version 1.0.0
Visual Studio 2012

like image 825
Bhavik Avatar asked Apr 14 '14 10:04

Bhavik


7 Answers

Only install this nuget:

Install-Package Microsoft.AspNet.WebApi.OwinSelfHost
like image 187
mggSoft Avatar answered Oct 04 '22 22:10

mggSoft


Finally was able to solve it by adding signalR dependencies before adding signalR from NuGet Packages
Step's I followed:

  1. Added Microsoft.Owin //version 2.0.1
  2. Added Microsoft.Owin.Security //version 2.0.1
  3. Added Microsoft Asp.Net SignalR

The reason I discovered was a problem with version 2.0.2 of Microsoft.Owin and Microsoft.Owin.Security and then adding a class named Startup.cs with following code:

using Microsoft.Owin;
using Owin;

[assembly: OwinStartup(typeof(webApp.Startup))]
namespace webApp
{
    public static class Startup
    {
        public static void Configuration(IAppBuilder app)
        {
            app.MapSignalR();
        }
    }
}  

Directly adding Microsoft Asp.Net SignalR from NuGet adds version 2.0.2 of Microsoft.Owin and Microsoft.Owin.Security which creates the problem.
Hope it helps someone...!!

like image 28
Bhavik Avatar answered Oct 05 '22 00:10

Bhavik


Update-Package Owin -Reinstall

worked for me

like image 20
Saboor Awan Avatar answered Oct 04 '22 22:10

Saboor Awan


Install Nuget Package: Microsoft.AspNet.Identity.Owin

like image 20
Arsen Khachaturyan Avatar answered Oct 04 '22 23:10

Arsen Khachaturyan


I had this same problem. Turns out my .csproj file the first line:

Project ToolsVersion="12.0" didn't match my other files. Changed it to:

Project ToolsVersion="14.0"

and no more compile issue.

like image 41
zillabyte Avatar answered Oct 04 '22 22:10

zillabyte


Using MVC5, enter your Startup.cs file.

Add IAppBuilder appBuilder to Configure():

 public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IAppBuilder appBuilder)
    {

Then, under

app.UseMvc(routes =>
{
    routes.MapRoute(
        name: "default",
        template: "{controller=Home}/{action=Index}/{id?}");
});

add appBuilder.MapSignalR();

like image 24
Adam Reed Avatar answered Oct 04 '22 23:10

Adam Reed


Asp.Net 5 empty mvc project out of the box creates something that looks like this

 using Microsoft.Owin;
using Owin;
namespace DeadlyChat
{
public class Startup
{
    // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940
    public void ConfigureServices(IServiceCollection services)
    {
    }

    public void Configure(IApplicationBuilder app)
    {
        app.MapSignalR();



       }
    }
}

Took me a while to notice that Configure was supposed to be Configuration and IApplicationBuilder needs to be IAppBuilder. I also pulled off the assembly annotation above the namespace.

I wound up scrapping trying to use Asp.Net 5 couldn't get it to work. Went back to 4.6 and everything worked fine. Followed this walkthrough http://www.asp.net/signalr/overview/getting-started/tutorial-getting-started-with-signalr

like image 27
DeadlyChambers Avatar answered Oct 04 '22 23:10

DeadlyChambers