Entity Framework LoaderExceptions Unable to load one or more of the requested types

I have a web service that uses an entity framework. When released to a test environment, I get the following error:

"Unable to load one or more of the requested types." - Stack trace below ...

The testbox has .NET 3.5 SP 1 installed and I read the previous post here:

Error message "One or more of the requested types could not be loaded. Get the LoaderExceptions property for more information."

However, the answer doesn't solve it in my case. I copied and pasted a working copy from my development machine to a test box to make sure there are no problems with the debug DLL (as the answer suggests), no luck however.

Is this a known issue? I spent a whole night trying to debug this! If anyone knows of a solution please let me know!

Retrieve the LoaderExceptions property for more information.   at System.Reflection.Module._GetTypesInternal(StackCrawlMark& stackMark)
   at System.Reflection.Assembly.GetTypes()
   at System.Data.Metadata.Edm.ObjectItemCollection.AssemblyCacheEntry.LoadTypesFromAssembly(LoadingContext context)
   at System.Data.Metadata.Edm.ObjectItemCollection.AssemblyCacheEntry.InternalLoadAssemblyFromCache(LoadingContext context)
   at System.Data.Metadata.Edm.ObjectItemCollection.AssemblyCacheEntry.LoadAssemblyFromCache(Assembly assembly, Boolean loadReferencedAssemblies, Dictionary`2 knownAssemblies, Dictionary`2& typesInLoading, List`1& errors)
   at System.Data.Metadata.Edm.ObjectItemCollection.LoadAssemblyFromCache(ObjectItemCollection objectItemCollection, Assembly assembly, Boolean loadReferencedAssemblies)
   at System.Data.Metadata.Edm.ObjectItemCollection.LoadAssemblyForType(Type type)
   at System.Data.Metadata.Edm.MetadataWorkspace.LoadAssemblyForType(Type type, Assembly callingAssembly)
   at System.Data.Objects.ObjectContext.CreateQuery[T](String queryString, ObjectParameter[] parameters)
   at Company.Domain.ICommuicationsEntities.CreateQuery[T](String queryString, ObjectParameter[] parameters)
   at Comany.EntityFrameworkRepository`1.GetQuery()
   at Comany.Repositories.EntityFrameworkRepository`1.GetFiltered(Expression`1 filter, IncludeBuilder`1 includeBuilder)
   at Comany.Repositories.EntityFrameworkRepository`1.GetFiltered(Expression`1 filter)

      

+2


source to share


3 answers


The top line of the stack says:

Get more information on LoaderExceptions .



You can find this by examining the exception in the debugger.

+2


source


The first line of the stack trace "Get the LoaderExceptions property for more information" is certainly the key to this. You need to catch the ReflectionTypeLoadException or throw a generic exception.

catch (System.Reflection.ReflectionTypeLoadException ex) {
    ex.LoaderExceptions;
} catch (Exception ex) {
    if (ex is System.Reflection.ReflectionTypeLoadException)
        ((System.Reflection.ReflectionTypeLoadException)ex).LoaderExceptions;
}

      



Then you can check the LoaderExceptions property to see which DLLs might be missing.

+1


source


System.IO.FileNotFoundException: Could not load file or assembly 'System.Web.Mvc, Version = 3.0.0.0, Culture = neutral, PublicKeyToken = 31bf3856ad364e35' or one of its dependencies. the system cannot find the file specified. Filename: 'System.Web.Mvc, Version = 3.0.0.0, Culture = neutral, PublicKeyToken = 31bf3856ad364e35'

WRN: Assembly binding registration is disabled. To enable assembly failure logging, set the registry value [HKLM \ Software \ Microsoft \ Fusion! EnableLog] (DWORD) to 1.

Note. There is some performance limitation associated with logging assembly binding failures. To disable this feature, delete the registry value [HKLM\Software\Microsoft\Fusion!EnableLog]

.

0


source







All Articles