Error message 'Unable to load one or more of t

2019-01-01 08:16发布

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, Dictionary2 knownAssemblies, Dictionary2& 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?

30条回答
后来的你喜欢了谁
2楼-- · 2019-01-01 08:38

I got this problem when I installed a NuGet package on one of the projects and forgot to update the other project.

I solved this by just making both projects having the same reference assembly.

查看更多
大哥的爱人
3楼-- · 2019-01-01 08:38

One solution that worked for me was to delete the bin/ and obj/ folders and rebuild the solution.

查看更多
低头抚发
4楼-- · 2019-01-01 08:39

It happened for me also. I solved the problem as follows: Right click Solution, Manage NuGet Packages for Solution... Consolidate packages and upgraded the packages to be in the same version.

查看更多
倾城一夜雪
5楼-- · 2019-01-01 08:39

If you're using the EntityDataSource in your project, the solution is in Fix: 'Unable to load one or more of the requested types' Errors. You should set the ContextTypeName="ProjectNameNameSpace.EntityContainerName" '

This solved my problems...

查看更多
君临天下
6楼-- · 2019-01-01 08:41

Verify that each of your projects is setup correctly in the Configuration Manager.

Similar to William Edmondson's reason for this issue, I switched my Configuration Manager setting from "Debug" "Any CPU" to "Debug" ".NET". The problem was that the ".NET" version was NOT configured to build ALL of the projects, so some of my DLLs were out of date (while others were current). This caused numerous problems with starting the application.

The temporary fix was to do Kenny Eliasson's suggestion to clean out the \bin and \obj directories. However, as soon as I made more changes to the non-compiling projects, everything would fail again.

查看更多
不流泪的眼
7楼-- · 2019-01-01 08:43

The solution was to check the LoaderException: In my case, some of the DLL files were missing.

Enter image description here

查看更多
登录 后发表回答