我使用实体框架,SQL Server 2000, Visual Studio 2008和企业库开发了一个应用程序。

它在本地工作得非常好,但是当我将项目部署到我们的测试环境时,我得到了以下错误:

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)

实体框架似乎有问题,任何线索如何修复它?


当前回答

在我的情况下,我有一个nuget包,安装在我的项目,但包文件夹从未检入到TFS,因此,在构建机器的nuget包bin文件丢失。因此在生产中我得到了这个错误。我不得不比较bin文件夹在生产和我的本地,然后我发现哪些dll是缺失的,我发现那些属于一个nuget包。

其他回答

这对我很管用。把它添加到你的web.config中

<system.web>
  <trust level="Full" />

我对这个问题的实例最终成为一个缺失的参考。在app.config中引用了一个程序集,但在项目中没有引用。

如果您在项目中使用EntityDataSource,解决方案是Fix:“无法加载一个或多个请求类型”错误。您应该设置ContextTypeName="ProjectNameNameSpace。EntityContainerName”

这解决了我的问题……

点击“查看异常详细信息”检查此属性:

解决方案是检查LoaderException:在我的情况下,一些DLL文件丢失了。