1

我正在尝试将 SignalR 1.x 集成到我的项目中(在 .net 4.0 上运行)。当我调用 RouteTable.Routes.MapHubs() 时,我遇到了一个问题。在配置任何其他路由之前,我正在 Global.asax 中的 Application_Start 中进行调用。

我最终得到这样的异常:

    [FileLoadException: API restriction: The assembly 'file:///C:\Users\Kyle\Documents\<Project>\bin\Debug\<Name>.dll' has already loaded from a different location. It cannot be loaded from a new location within the same appdomain.]
   System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
   System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +34
   System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +152
   System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark) +102
   System.Reflection.Assembly.ReflectionOnlyLoadFrom(String assemblyFile) +34
   Owin.Loader.DefaultLoader.GetDefaultConfigurationString(Func`2 defaultTypeNames) +774
   Owin.Loader.DefaultLoader.LoadImplementation(String startupName) +177
   Owin.Loader.DefaultLoader.Load(String startupName) +45
   Microsoft.Owin.Host.SystemWeb.OwinBuilder.Build() +167
   System.Lazy`1.CreateValue() +416
   System.Lazy`1.LazyInitValue() +152
   System.Lazy`1.get_Value() +75
   Microsoft.Owin.Host.SystemWeb.OwinApplication.get_Instance() +35
   Microsoft.Owin.Host.SystemWeb.OwinHttpModule.Init(HttpApplication context) +106
   System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +418
   System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +172
   System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +336
   System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +296

请注意,当我调用 RouteTable.Routes.MapHubs() 时不会发生错误,而是在稍后发出请求时发生。谷歌搜索揭示了这个问题:

https://github.com/owin/owin-hosting/issues/17

但我无法升级,因为 SignalR 2.x 需要 .net 4.5。

4

1 回答 1

1

答案似乎是升级 owin 包而不升级 SignalR 包。所以使用 NuGet:

Install-Package Microsoft.Owin.Host.SystemWeb -Version 2.0.1 
Install-Package Microsoft.AspNet.SignalR.SystemWeb -Version 1.1.3 
于 2013-11-13T15:35:45.063 回答