C# 无法加载文件或程序集错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/552490/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-04 07:51:28  来源:igfitidea点击:

Could not load file or assembly error

c#winformsdependencies

提问by leora

Can anyone help me figure out what the problem is. I am trying to start up a C# winformsa app in visual studio and i keep getting this error:

谁能帮我弄清楚问题是什么。我正在尝试在 Visual Studio 中启动 C# winformsa 应用程序,但我不断收到此错误:

Could not load file or assembly, Foo.dll version1.93343 or one of its dependencies The system can't find the file specified

无法加载文件或程序集,Foo.dll version1.93343 或其依赖项之一系统找不到指定的文件

vs 2005, C# 2.0

与 2005 年相比,C# 2.0

any help

任何帮助

采纳答案by Gerrie Schenck

Typically it's about one of your references' reference, possibly deep down in the dependency tree. What I usually do is, fire up Sysinternals Process Monitor (http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx), filter by process name, and run the app. It's typically fairly easy at this point to sift through the FILE NOT FOUNDs and locate the offending missing reference.

通常它是关于你的引用的引用之一,可能在依赖树的深处。我通常做的是,启动 Sysinternals Process Monitor ( http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx),按进程名称过滤,然后运行应用程序。在这一点上通常很容易筛选 FILE NOT FOUNDs 并找到有问题的缺失参考。

回答by Ed S.

You must have a reference to Foo.dll somewhere and it can't be located (duh). Do you see a reference in the solution window? You can right click that and select "properties" to look at the path.

您必须在某处引用 Foo.dll 并且无法找到它(废话)。您在解决方案窗口中看到参考了吗?您可以右键单击它并选择“属性”以查看路径。

回答by Canavar

Do you see an exclamation mark on a reference in visual studio's solution explorer ?

您是否在 Visual Studio 的解决方案资源管理器中看到参考文献上有感叹号?

If so, then you need to remove it then add it again.

如果是这样,那么您需要将其删除,然后再次添加。

回答by Ash

This is the key part: "or one of its dependencies"

这是关键部分:“或其依赖项之一”

I've often found that the assembly dll file that can't be loaded looks fine. However one of its dependencies (another assembly dll) does not exist or has been moved.

我经常发现无法加载的程序集dll文件看起来很好。但是,它的一个依赖项(另一个程序集 dll)不存在或已被移动。

When the CLR loads an assembly it will also check that all of that assemblies dependencies exist. In XCopy deployment this normally means you need all the dependency assemblies in the same directory as your application exe.

当 CLR 加载程序集时,它还会检查所有这些程序集依赖项是否存在。在 XCopy 部署中,这通常意味着您需要与应用程序 exe 位于同一目录中的所有依赖程序集。

Try loading the winforms executable into Reflectorand under "yourApp.exe" expand the References node to see what the other referenced types are.

尝试将 winforms 可执行文件加载到Reflector 中,然后在“yourApp.exe”下展开 References 节点以查看其他引用类型。

回答by Gerrie Schenck

Fire up Fuslogvw.exe and inspect which assembly (or reference) can't be found.

启动Fuslogvw.exe 并检查无法找到哪个程序集(或参考)。

回答by Chris Haines

Worth checking your global web.config hasn't got a reference to that assembly

值得检查您的全局 web.config 没有引用该程序集