LoaderExceptions in Entity Framework One or more of the specified types could not be loaded.



I have a Web Service that uses the entity framework. When releasing to a test environment, I receive the following error:

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

The test box has .NET 3.5 SP 1 installed, and I have read a previous post here:

Error message 'Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.'

However the answer does not solve it in my case. I have copied and pasted the working copy off my development machine onto the test box to ensure there is not a problem with debug DLLs (as the answer suggests), however no luck.

Is this a known issue? Ive spent an entire morning 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)
5/23/2017 12:19:40 PM

Accepted Answer

As the top line of the stack says:

Retrieve the LoaderExceptions property for more information.

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

9/21/2009 2:24:58 PM

Popular Answer

The first line of the stack trace "Retrieve the LoaderExceptions property for more information" is definitely the key to this. You'll need to catch the ReflectionTypeLoadException or cast your general exception.

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

You can then check the LoaderExceptions property to find out what DLL references might be missing.

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow