gpt4 book ai didi

c# - 错误消息 'Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.'

转载 作者:太空宇宙 更新时间:2023-11-03 16:06:17 25 4
gpt4 key购买 nike

我已经使用 Entity Framework 开发了一个应用程序、SQL Server 2000、Visual Studio 2008 和 Enterprise Library。

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

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 似乎有问题,有什么解决办法吗?

最佳答案

此错误没有真正 Elixir 的答案。关键是要有所有的信息来理解问题。很可能动态加载的程序集缺少引用的程序集。该程序集需要位于应用程序的 bin 目录中。

使用此代码确定缺少的内容。

using System.IO;
using System.Reflection;
using System.Text;

try
{
//The code that causes the error goes here.
}
catch (ReflectionTypeLoadException ex)
{
StringBuilder sb = new StringBuilder();
foreach (Exception exSub in ex.LoaderExceptions)
{
sb.AppendLine(exSub.Message);
FileNotFoundException exFileNotFound = exSub as FileNotFoundException;
if (exFileNotFound != null)
{
if(!string.IsNullOrEmpty(exFileNotFound.FusionLog))
{
sb.AppendLine("Fusion Log:");
sb.AppendLine(exFileNotFound.FusionLog);
}
}
sb.AppendLine();
}
string errorMessage = sb.ToString();
//Display or log the error based on your application.
}

关于c# - 错误消息 'Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19203278/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com