DefaultLoader.cs: The assembly has already loaded from a different location

Nov 12, 2013 at 9:10 PM
I'm having an issue integrating SignalR 1.x into my existing .Net 4.0 web application. The part where it fails gives me a stack trace pointing back to Owin. The trace looks like this:
 [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
I have found someone else with the same problem, but since I can't upgrade to 2.x (since I'm not on .net 4.5), I'm still at a loss.

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

Thanks.
Coordinator
Nov 12, 2013 at 9:17 PM
Can you try upgrading just the Katana components (Microsoft.Owin.*) to v2.0? Most of our v2.0 components still have .Net 4.0 support.
Nov 12, 2013 at 9:25 PM
Yes, I can try that...It's just that I won't be able to use NuGet, so I'll have to figure out how to add the assemblies manually.


Coordinator
Nov 12, 2013 at 9:31 PM
VS and Nuget should let you upgrade just the Katana packages. Check docs.nuget.org if you're getting lost.
Nov 13, 2013 at 2:03 PM
Actually installing the packages isn't difficult. What's more difficult is determining which packages need to be installed, since the packages appears to have changed. For example, here is the dependency tree:


Microsoft.AspNet.SignalR.SystemWeb 1.1.3
+ Microsoft.AspNet.SignalR.Owin >= 1.1.3
+ Microsoft.AspNet.SignalR.Core >= 1.1.3
+Newtonsoft.Json
+ Owin >= 1.0
+ Microsoft.Owin.Host.SystemWeb >= 1.0.1
+ Owin >=1.0
+ Microsoft.Web.Infrastructure >=1.0.0.0

The problem is that there is no 2.0.1 version of 'Microsoft.AspNet.SignalR.Owin'. Maybe this would be a questions for the SignalR mailing list instead.

-Kyle



Nov 13, 2013 at 2:33 PM
Ok, I spoke too soon. It was easier than I thought. This seemed to have fixed my problems:

Install-Package Microsoft.Owin.Host.SystemWeb -Version 2.0.1 -Project WebClientLibrary
Install-Package Microsoft.AspNet.SignalR.SystemWeb -Version 1.1.3 -Project WebClientLibrary