'Owin.IAppBuilder' does not contain a definition for 'MapSignalR'
Asked Answered
C

7

38

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

Cathodoluminescence answered 14/4, 2014 at 10:13 Comment(0)
H
50

Only install this nuget:

Install-Package Microsoft.AspNet.WebApi.OwinSelfHost
Horizontal answered 23/12, 2014 at 10:35 Comment(1)
Need to install this nuget too: Install-Package Microsoft.Owin.Cors -Version 3.1.0Strikebound
C
26

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...!!

Cathodoluminescence answered 14/4, 2014 at 13:45 Comment(4)
Thanks! You saved me from getting very frustrated on a Friday night!Again
FYI as of 2/15/2015 this seems to have been resolved. I only installed Microsoft.AspNet.SignalR directly and the above worked fine.Brotherhood
This is an old solution. Do refer the answer by @Horizontal for the latest answer.Cathodoluminescence
Thank you so much my friend... your solution solved my problem which I was working for 1 hours...Broyles
R
14
Update-Package Owin -Reinstall

worked for me

Rodrigo answered 28/4, 2015 at 14:22 Comment(1)
Worked for me too thank you. I tried the other solutions above and they did not work. This one did.Smoodge
C
4

Install Nuget Package: Microsoft.AspNet.Identity.Owin

Choli answered 27/1, 2019 at 18:30 Comment(0)
H
3

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.

Hydrated answered 28/9, 2015 at 2:53 Comment(0)
G
3

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();

Gentian answered 26/12, 2015 at 6:3 Comment(0)
T
1

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

Thermoscope answered 24/5, 2015 at 4:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.