I have developed an application using Entity Framework, SQL Server 2000, Visual Studio 2008 and Enterprise Library.
It works absolutely fine locally, but when I deploy the project to our test environment, I am getting the following error:
Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information
Stack trace: 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)
Entity Framework seems to have issue, any clue how to fix it?
This error has no true magic bullet answer. The key is to have all the information to understand the problem. Most likely a dynamically loaded assembly is missing a referenced assembly. That assembly needs to be in the bin directory of your application.
Use this code to determine what is missing.
Initially I tried the Fusion log viewer, but that didn't help so I ended up using WinDbg with the SOS extension.
!dumpheap -stat -type Exception /D
Then I examined the FileNotFoundExceptions. The message in the exception contained the name of the DLL that wasn't loading.
N.B., the /D give you hyperlinked results, so click on the link in the summary for FileNotFoundException. That will bring up a list of the exceptions. Then click on the link for one of the exceptions. That will !dumpobject that exceptions. Then you should just be able to click on the link for Message in the exception object, and you'll see the text.
I changed the Specific Version Property of the Refrences to false and that helped.
I am able to fix this issue by marking "Copy Local=True" on all referenced DLL files in the project, rebuilding and deploying on a testing server.
Another solution to know why exactly nothing works (from Microsoft connect):
Add this code to the project:
Turn off generation serialization assemblies.
I solved this issue by setting the Copy Local attribute of my project's references to true.