4
votes

Error

The type or namespace name 'OwinStartupAttribute' could not be found
The type or namespace name 'OwinStartup' could not be found

Code

using Microsoft.Owin;
using Owin;

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

Any help would be appreciated.

Using:

  • .net 4.0
  • MVC 4
  • Microsoft.AspNet.SignalR.SystemWeb (1.1.0.0)
  • Microsoft.Owin (2.1.0.0)
  • Microsoft.Owin.Host.SystemWeb (2.1.0.0)
  • Owin (1.0.0.0)
  • Visual Studio 2013

Installed singlar after Referencing Microsoft.Owin using the command Install-Package Microsoft.AspNet.SignalR -Version 1.1.3

UPDATE: I removed [assembly:.. and also added this in web.config: <add key="owin:AppStartup" value="Employee.Web.Models.Startup" />

The error now says
'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

3
I tested signalr with Asp.net web application using .net4.5. All was fine. Now trying to integrate in .net4.0 mvc4 and these errors pop upQwerty

3 Answers

2
votes

To fix that:

  1. Make sure that Microsoft.Owin is installed
  2. Right-click on the project and click add item and search for "startup"
  3. Now, you already have an OWIN Startup.cs class. click on OWIN Startup class and just add it under Startup1.cs then the error will be gone.
  4. Delete the added Startup1.cs

finally, rebuild.

Hope that helps!

1
votes

Create One Class With Name Startup this will help you..

public class Startup
{
   public void Configuration(IAppBuilder app)
   {
      app.MapSignalR();
   }
}

In addition to this, if your startup class is somehow not in your default name space, add a web config line to the area like: <add key="owin:AppStartup" value="[NameSpace].Startup" />

Here is more explenation.

1
votes
  1. I removed Microsoft.Owin from my project's references
  2. downloaded the .dll and placed it into the project's bin/ folder
  3. Right clicked references, add, browse, find the .dll, it builds!
  4. Make sure the packages.config version of Owin matches your downloaded version.