owin/museum-piece-owin-hosting

DefaultLoader.cs attempts to load already loaded assemblies

Closed this issue · 2 comments

This method of loading all assemblies to look for a special class seems irresponsible. Do I really want all of my assemblies loaded because I'm using SignalR? At a minimum this needs to be caught.

[FileLoadException: API restriction: The assembly 'file:///C:\MYREPO\Source\MYAPP\bin\System.Web.Mvc.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(Func2 defaultTypeNames) +676 Owin.Loader.DefaultLoader.LoadImplementation(String startupName) +99 Owin.Loader.DefaultLoader.Load(String startupName) +18 Microsoft.Owin.Host.SystemWeb.OwinBuilder.Build() +71 System.Lazy1.CreateValue() +180
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +22
System.Lazy`1.get_Value() +10785869
Microsoft.Owin.Host.SystemWeb.OwinHttpModule.Init(HttpApplication context) +43
System.Web.HttpApplication.InitModulesCommon() +80
System.Web.HttpApplication.InitModules() +64
System.Web.HttpApplication.InitInternal(HttpContext context, HttpApplicationState state, MethodInfo[] handlers) +792
System.Web.HttpApplicationFactory.GetNormalApplicationInstance(HttpContext context) +336
System.Web.HttpApplicationFactory.GetApplicationInstance(HttpContext context) +107
System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +525

[Owin.Loader is now being maintained over at katanaproject.codeplex.com.]

This Exception is a known issue and has been fixed in for 2.0.0-RC1. (Not sure if the fix was in Beta2).

For reference, the assembly scanning is optional and only happens if no startup class is specified in the AppSettings config. Note that SignalR and WebApi will also scan all the assemblies looking for Hubs and Controllers.

Thanks!