EF4 Unable to load one or more of the requested types on test server
I developed an ASP.NET v4 application using Entity Framework 4. I'm deploying it to the test server (Windows 2008 R2 with .NET Framework 4 installed).
The application throws this error:
[ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.]
System.Reflection.RuntimeModule.GetTypes(RuntimeModule module) +0 System.Reflection.Assembly.GetTypes() +144 System.Data.Metadata.Edm.ObjectItemConventionAssemblyLoader.LoadTypesFromAssembly() +45 System.Data.Metadata.Edm.ObjectItemAssemblyLoader.Load() +34 System.Data.Metadata.Edm.AssemblyCache.LoadAssembly(Assembly assembly, Boolean loadReferencedAssemblies, ObjectItemLoadingSessionData loadingData) +130 System.Data.Metadata.Edm.AssemblyCache.LoadAssembly(Assembly assembly, Boolean loadReferencedAssemblies, KnownAssembliesSet knownAssemblies, EdmItemCollection edmItemCollection, Action1 logLoadMessage, Object& loaderCookie, Dictionary
2& typesInLoading, List1& errors) +248 System.Data.Metadata.Edm.ObjectItemCollection.LoadAssemblyFromCache(ObjectItemCollection objectItemCollection, Assembly assembly, Boolean loadReferencedAssemblies, EdmItemCollection edmItemCollection, Action
1 logLoadMessage) +580 System.Data.Metadata.Edm.ObjectItemCollection.ImplicitLoadAssemblyForType(Type type, EdmItemCollection edmItemCollection) +121 System.Data.Metadata.Edm.MetadataWorkspace.ImplicitLoadAssemblyForType(Type type, Assembly callingAssembly) +178 System.Data.Objects.ObjectContext.GetTypeUsage(Type entityCLRType) +49 System.Data.Objects.ObjectContext.CreateObjectSet(String entitySetName) +163 PageManager.FetchDefaultPage() +114
When I look on my development PC 开发者_如何学CI see this directory with assemblies:
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0
But on the server the whole .NETFramework directory is missing, there is just a v3.0 and v3.5 directory. I assume the server is using the assembly from one of these directories which are version 3.5.0.0 and not 4.0.0.0 (what my app is referencing).
What do I need to install? .NET 4 is installed on the server i'm 100% sure.
The problem was nothing to do with .NET 4. I caught the ReflectionTypeLoadException and looped the LoaderExceptions. References to Microsoft.SyncronisationFramework were missing.
Perhaps a direct message in the exception with a list of missing references would be nice.
I believe your question is answered here: http://msdn.microsoft.com/en-us/library/cc656912.aspx
精彩评论