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

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


当前回答

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

其他回答

我的问题已解决后,我删除多余的程序集文件从bin文件夹。

我有一个。net 4.0, ASP。NET MVC 2.0,实体框架4.0 web应用程序开发在Visual Studio 2010。我遇到了同样的问题,它在一台Windows Server 2008 R2服务器上工作,但在另一台Windows Server 2008 R2服务器上不能工作,即使。net和ASP。NET MVC是一样的,抛出和你的一样的错误。

我听从了miko的建议,所以我在故障服务器上安装了Windows SDK v7.1 (x64),这样我就可以运行!dumpheap了。

事实证明,安装Windows SDK v7.1 (x64)解决了这个问题。任何缺失的依赖项都必须包含在SDK中。它可以从微软Windows SDK for Windows 7和。net Framework 4下载。

正如之前所提到的,通常情况下,组装不存在。

要确切地知道您丢失了什么程序集,请附加调试器,设置断点,当您看到异常对象时,钻到'LoaderExceptions'属性。丢失的程序集应该在那里。

希望能有所帮助!

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

我改变了引用的特定版本属性为假,这有助于。