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:21

My instance of this problem ended up being a missing reference. An assembly was referred to in the app.config but didn't have a reference in the project.

查看更多
人间绝色
3楼-- · 2019-01-01 08:21

This worked for me. Add it in your web.config

<system.web>
  <trust level="Full" />
查看更多
弹指情弦暗扣
4楼-- · 2019-01-01 08:21

I had an issue with automap. In the bin folder, the file automap.4net.dll was there, but for some reason the automap.xml and automap.dll weren't. Copying them to the bin directory solved the issue.

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

Two possible solutions:

  1. You are compiling in Release mode but deploying an older compiled version from your Debug directory (or vise versa).
  2. You don't have the correct version of the .NET Framework installed in your test environment.
查看更多
几人难应
6楼-- · 2019-01-01 08:25

Adding my specific problem/solution to this as this is the first result for this error message. In my case, the error was received when I deployed a second application within the folder of my first application in IIS. Both were defining connection string with the same name resulting in the child application having a conflict and in turn generating this (to me) non-obvious error message. It was solved by adding:

<clear/>

in the connection string block of the child web application which prevented it from inheriting the connection strings of web.config files higher in the hierarchy, so it looks like:

<connectionStrings>
  <clear/>
  <add name="DbContext" connectionString="MySERVER" providerName="System.Data.SqlClient" />
</connectionStrings>

A reference Stack Overflow question which helped once I determined what was going on was Will a child application inherit from its parent web.config?.

查看更多
柔情千种
7楼-- · 2019-01-01 08:26

I had a .NET 4.0, ASP.NET MVC 2.0, Entity Framework 4.0 web application developed in Visual Studio 2010. I had the same problem, that it worked on one Windows Server 2008 R2 server but not on another Windows Server 2008 R2 server, even though the versions of .NET and ASP.NET MVC were the same, throwing this same error as yours.

I went to follow miko's suggestion, so I installed Windows SDK v7.1 (x64) on the failing server, so I could run !dumpheap.

Well, it turns out that installing Windows SDK v7.1 (x64) resolved the issue. Whatever dependency was missing must have been included in the SDK. It can be downloaded from Microsoft Windows SDK for Windows 7 and .NET Framework 4.

查看更多
登录 后发表回答