[英]Could not load file or assembly 'Microsoft.Bcl.AsyncInterfaces, Version=1.0.0.0, Culture=neutral, PublicKeyToken=XX' or one of its dependencies
[英]Could not load file or assembly 'XXX, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies
我一直在尝试调试此错误:
System.IO.FileNotFoundException:无法加载文件或程序集'ClassLibrary1,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = null'或其依赖项之一。 该系统找不到指定的文件。 文件名:'ClassLibrary1,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = null'
我看到了很多解决方案,并尝试了所有解决方案。
我正在查看Fusion Viewer,并且收到以下消息:
日志:此绑定在默认的加载上下文中启动。 日志:使用应用程序配置文件:I:\\ Projects \\ ACE Explorer \\ AceV_1Explorer \\ AceExplorer \\ AceExplorer \\ bin \\ Debug \\ AceExplorer.exe.config日志:使用主机配置文件:日志:使用来自C:\\ Windows \\ Microsoft的计算机配置文件.NET \\ Framework64 \\ v4.0.30319 \\ config \\ machine.config。 日志:政策后参考:ClassLibrary1,版本= 1.0.0.0,区域性=中性,PublicKeyToken =空日志:GAC查找失败。 日志:尝试下载新的URL文件:/// I:/ Projects / ACE Explorer / AceV_1Explorer / AceExplorer / AceExplorer / bin / Debug / ClassLibrary1.DLL。 日志:尝试下载新的URL文件:/// I:/ Projects / ACE Explorer / AceV_1Explorer / AceExplorer / AceExplorer / bin / Debug / ClassLibrary1 / ClassLibrary1.DLL。 日志:尝试下载新的URL文件:/// I:/ Projects / ACE Explorer / AceV_1Explorer / AceExplorer / AceExplorer / bin / Debug / ClassLibrary1.EXE。 日志:尝试下载新的URL文件:/// I:/ Projects / ACE Explorer / AceV_1Explorer / AceExplorer / AceExplorer / bin / Debug / ClassLibrary1 / ClassLibrary1.EXE。 日志:所有探测URL尝试失败。
我在目录中看到该文件,并且使用x86的目标框架均为4.0
找出损坏的任何想法
抱歉,已更新 。 在日志中是PublicKeyToken = null。 我正在尝试一切。
UPDATE我在主程序中添加了一些代码,这些代码将使用ResolveEventHandler解析程序集。 起初它没有用。 但是,当我让程序在程序开始时加载那些外部程序集(LoadReferences())时,它确实可以工作。 奇怪的是,当我在开始的LoadReferences()中加载它们,然后当该方法输入对触发CurrentDomain_AssemblyResolve的自定义程序集的引用时,该路径是完全相同的。 空白路径解析为Assemblypath。 如您所见,在LoadReferences()中,我添加了EntityFramework,即使我使用的是Nuget,它也会引起相同的问题。
在Main()中,我添加了:
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
LoadReferences();
private static void LoadReferences()
{
Assembly objExecutingAssemblies;
objExecutingAssemblies = Assembly.GetExecutingAssembly();
AssemblyName[] arrReferencedAssmbNames = objExecutingAssemblies.GetReferencedAssemblies();
Assembly asm;
foreach (AssemblyName strAssmbName in arrReferencedAssmbNames)
{
if (strAssmbName.FullName.ToLower().Contains("[company].") || strAssmbName.FullName.ToLower().Contains("entityframework"))
asm = Assembly.LoadFrom(Path.Combine("", strAssmbName.FullName.Substring(0, strAssmbName.FullName.IndexOf(","))+ ".dll"));
}
// these were also posing an issue
asm = Assembly.LoadFrom(Path.Combine("", "EntityFramework.dll"));
asm = Assembly.LoadFrom(Path.Combine("", "EntityFramework.SqlServer.dll"));
}
static System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{
string assembliesDir = "";
try
{
string dll = (args.Name.IndexOf(",") < 0 ? args.Name + ".dll" : args.Name.Substring(0, args.Name.IndexOf(",")) + ".dll");
Assembly asm = Assembly.LoadFrom(Path.Combine(assembliesDir, dll));
return asm;
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
return null;
}
也。 不知道这是否有所作为,但这是一次完全信任的单击。
此外,我们的台式机已被锁定。
此外,所有项目的平台都设置为x86。
文件:/// I:/ Projects / ACE Explorer /.../ bin / Debug / ClassLibrary1.DLL。
这个问题需要心理调试。 要求Fusion解析I:
驱动器上的路径。 这通常是映射到文件服务器上共享的驱动器号。 经常这样麻烦。 考虑到对安全性的过分关注,ACE易于成为Access Control Entry的缩写。 这使得程序很可能使用模拟来“探索”访问权限。 这使得Fusion可能无法弄清楚I:
驱动器可能指的是什么,驱动器映射是针对每个用户的设置。
在程序早期可以正常工作,因为它仍使用默认的用户令牌运行。 程序一旦部署,就可以正常工作,因为它现在的位置稳定,不再依赖于驱动器号映射。
我不确定要提出什么建议,我是《日内瓦程序员权利公约》的特许成员。 这就要求程序员可以在本地驱动器上创建和测试程序,并安装所需的调试工具,以查明其程序为何不起作用。 这是您的IT员工需要解决的问题。 如果这样可以让您控制自己的开发机器,那么您将遥遥领先。 考虑到Google对于“映射驱动器上的.net调试项目”查询返回的命中情况,可能会产生结果。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.