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

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


当前回答

我通过将项目引用的Copy Local属性设置为true来解决这个问题。

其他回答

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

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

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

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

希望能有所帮助!

两种可能的解决方案:

您正在以发布模式编译,但从Debug目录部署了较旧的编译版本(反之亦然)。 您的测试环境中没有安装正确的. net Framework版本。

我也是这样。我的解决方法如下: 右键单击解决方案,管理解决方案的NuGet包… 合并包并将包升级为相同的版本。

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