C# 未知模块中发生类型为“System.IO.FileNotFoundException”的未处理异常

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9729691/
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-09 08:37:01  来源:igfitidea点击:

An unhandled exception of type 'System.IO.FileNotFoundException' occurred in Unknown Module

c#exceptionruntime

提问by mj1261829

I am developing a c# application and I get the following error at debug runtime:

我正在开发 ac# 应用程序,在调试运行时出现以下错误:

An unhandled exception of type 'System.IO.FileNotFoundException' occurred in Unknown Module.

Additional information: Could not load file or assembly 'Autodesk.Navisworks.Timeliner.dll' or one of its dependencies. The specified module could not be found.

未知模块中发生类型为“System.IO.FileNotFoundException”的未处理异常。

附加信息:无法加载文件或程序集“Autodesk.Navisworks.Timeliner.dll”或其依赖项之一。指定的模块无法找到。

Autodesk.Navisworks.Timeliner.dll is in the debug folder of the application. I have repaired the .net framework (version 4) but it did not resolve it. Any ideas on how to resolve this issue? Thanks.

Autodesk.Navisworks.Timeliner.dll 位于应用程序的调试文件夹中。我已经修复了 .net 框架(版本 4)但它没有解决它。有关如何解决此问题的任何想法?谢谢。

采纳答案by Andrew Shepherd

First check - is the working directory the directory that the application is running in:

首先检查 - 工作目录是应用程序运行的目录:

  • Right-click on your project and select Properties.
  • Click the Debug tab.
  • Confirm that the Working directory is either empty or equal to the bin\debug directory.
  • 右键单击您的项目并选择属性。
  • 单击调试选项卡。
  • 确认工作目录为空或等于 bin\debug 目录。

If this isn't the problem, then ask if Autodesk.Navisworks.Timeliner.dll is requiring another DLL which is not there. If Timeliner.dll is not a .NET assembly, you can determine the required imports using the command utility DUMPBIN.

如果这不是问题,则询问 Autodesk.Navisworks.Timeliner.dll 是否需要另一个不存在的 DLL。如果 Timeliner.dll 不是 .NET 程序集,您可以使用命令实用程序确定所需的导入DUMPBIN

dumpbin /imports Autodesk.Navisworks.Timeliner.dll

If it is a .NET assembly, there are a number of tools that can check dependencies.

如果是 .NET 程序集,则有许多工具可以检查依赖项。

Reflectorhas already been mentioned, and I use JustDecompilefrom Telerik.

Reflector已经提到过,我JustDecompile从 Telerik使用。



另见 this question这个问题

回答by Micah Armantrout

What I would do is use this tool and step through where you are getting the exception

我会做的是使用此工具并逐步完成您遇到异常的地方

http://www.reflector.net/

http://www.reflector.net/

Read this it will tell you how to create PDB's so you do not have to have all your references setup.

阅读本文,它将告诉您如何创建 PDB,这样您就不必设置所有引用。

http://www.cplotts.com/2011/01/14/net-reflector-pro-debugging-the-net-framework-source-code/

http://www.cplotts.com/2011/01/14/net-reflector-pro-debugging-the-net-framework-source-code/

It is a trial and I am not related to redgate at all I just use there software.

这是一个试用版,我与 redgate 完全没有关系,我只是使用那里的软件。

回答by Yaur

If you are running on a 64 bit system and trying to load a 32 bit dll you need to compile your application as 32 bit instead of any cpu. If you are not doing this it behaves exactly as you describe.

如果您在 64 位系统上运行并尝试加载 32 位 dll,您需要将应用程序编译为 32 位而不是任何 cpu。如果您不这样做,它的行为与您描述的完全一样。

If that isn't the case use Dependency Walkerto verify that the dll has its required dependencies.

如果不是这种情况,请使用Dependency Walker来验证 dll 是否具有其所需的依赖项。

回答by Nanu

Enable this option in VS: Just My Code option

在 VS 中启用此选项:仅我的代码选项

Tools -> Options -> Debugging -> General -> Enable Just My Code (Managed only)

工具 -> 选项 -> 调试 -> 常规 -> 仅启用我的代码(仅限托管)

回答by Aravind R S

Add following codesnippet in your cofig file

在您的配置文件中添加以下代码片段

<startup useLegacyV2RuntimeActivationPolicy="true">
   <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>

回答by Jimmy

For me it was occurring in a .net project and turned out to be something to do with my Visual Studio installation. I downloaded and installed the latest .net core sdk separately and then reinstalled VS and it worked.

对我来说,它发生在 .net 项目中,结果与我的 Visual Studio 安装有关。我单独下载并安装了最新的 .net core sdk,然后重新安装了 VS,它工作正常。