2014-03-24 77 views
3

我在asp.net mvc的與SignalR問題 我下面添加一個包: enter image description hereOwinStartup並在asp.net mvc的signalr啓動

,並添加Startup.cs

using Microsoft.Owin; 
using Owin; 
[assembly: OwinStartup(typeof(Paksh.Startup))] 
namespace Paksh 
{ 
    public class Startup 
    { 
     public static void ConfigureSignalR(IAppBuilder app) 
     { 
        app.MapSignalR(); 
     } 
    } 
} 

但我得到的錯誤:

The following errors occurred while attempting to load the app. - The OwinStartupAttribute.FriendlyName value '' does not match the given value 'ProductionConfiguration' in Assembly 'Paksh, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. - The given type or method 'ProductionConfiguration' was not found. Try specifying the Assembly. To disable OWIN startup discovery, add the appSetting owin:AutomaticAppStartup with a value of "false" in your web.config. To specify the OWIN startup Assembly, Class, or Method, add the appSetting owin:AppStartup with the fully qualified startup class or configuration method name in your web.config.

回答

9

錯誤中明確指出

The given [...] method 'ProductionConfiguration' was not found.

這意味着OWIN Startup Class Detection正在尋找一種方法,稱爲ProductionConfiguration您提供的類型(Paksh.Startup),但無法找到它。有個聲音告訴我,你有你的的web.config以及與此類似:

<appSettings> 
    <add key="owin:appStartup" value="ProductionConfiguration" />  
</appSettings> 

您有幾種選擇來解決這個問題:

  1. 更改ConfigureSignalR方法ProductionConfiguration名稱
  2. OwinStartupAttribute指定正確的方法名稱:[assembly: OwinStartup(typeof(Paksh.Startup), "ConfigureSignalR")]

要了解OWIN啓動類檢測,請閱讀更多here

0

我對OP有類似的錯誤,但使用屬性而不是web.config。我:

[assembly: OwinStartup("Configuration", typeof(StartUp))] 
namespace WebPipes 
{ 
    public class StartUp 
    { 
     public void Configuration(IAppBuilder app) 
     { 
      GlobalConfiguration.Configuration.UseSqlServerStorage("HangfireDB"); 

      app.UseHangfireServer(); 
      app.UseHangfireDashboard(); 
     } 
    } 
} 

OwinStartup的參數是不正確的,第一個參數表示友好名稱,而不是方法名。下面的代碼確實有效:

[assembly: OwinStartup(typeof(StartUp), "Configuration")] 
namespace WebPipes 
{ 
    public class StartUp 
    { 
     public void Configuration(IAppBuilder app) 
     { 
      GlobalConfiguration.Configuration.UseSqlServerStorage("HangfireDB"); 

      app.UseHangfireServer(); 
      app.UseHangfireDashboard(); 
     } 
    } 
}