我使用实体框架,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)

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


当前回答

如果您在PowerShell中引用.dll时遇到此错误,而您的.dll是. net 5(。),那么你应该确保你在PowerShell 6+而不是Windows PowerShell 5.1(或更早的版本)中执行PowerShell脚本。这在一个特定的场景中帮助了我。

其他回答

我能够通过在项目中所有引用的DLL文件上标记“复制本地=True”来修复这个问题,在测试服务器上重新构建和部署。

还要检查在.csproj文件中是否没有<Private>True</Private>用于未加载的程序集

我在使用ASP时遇到了这个错误。NET 4 + SQL Server 2008 R2 +实体框架4应用程序。

它在我的开发机器(Windows Vista 64位)上工作得很好。然后,当部署到服务器(Windows server 2008 R2 SP1)时,它将一直工作到会话超时。因此,我们部署应用程序,一切看起来都很好,然后让它超过20分钟的会话超时,然后抛出这个错误。

为了解决这个问题,我使用Ken Cox博客上的代码来检索LoaderExceptions属性。

对于我的情况,缺失的DLL是Microsoft.ReportViewer.ProcessingObjectModel(版本10)。这个DLL需要安装在运行应用程序的机器的GAC中。您可以在微软下载站点上的Microsoft Report Viewer 2010 Redistributable Package中找到它。

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

如果部署到IIS,请确保允许在IIS上使用32位应用程序。您可以在当前应用程序池的设置上定义这一点。