简体   繁体   English

c#中类型为'System.IO.FileNotFoundException'的未处理异常

[英]An Unhandled exception of type 'System.IO.FileNotFoundException' in c#

I have an old C# .NET windows application having C# user interface and all the code behind processing is done by calling C++ dll (C++ class library project) which is added as a reference to the C# project. 我有一个具有C#用户界面的旧C#.NET Windows应用程序,所有处理背后的代码都是通过调用C ++ dll(C ++类库项目)来完成的,该C ++ DLL被添加为对C#项目的引用。

However, after a long time, I am trying to run my project, which was backed up. 但是,经过很长一段时间,我试图运行已备份的项目。 Running it in visual studio 2005 gave the following exception: 在Visual Studio 2005中运行它会产生以下异常:

An unhandled exception of type 'System.IO.FileNotFoundException' occurred in System.Windows.Forms.dll

Additional information: The specified module could not be found. (Exception from HRESULT: 0x8007007E)

This exception is thrown when I try to debug the following code (for example) in the InitializeComponent() event. 当我尝试在InitializeComponent()事件中调试以下代码时,将引发此异常。

public CSPVMain(string[] args)
{
    InitializeComponent();
    ParseArgument(args);
}

However, the exception is actually shown to be thrown on this line even though the form gets loaded without no problems: 但是,即使加载窗体没有任何问题,实际上也显示该行抛出了异常:

Application.Run(new Form1());

Besides that, when I run the code by using Ctrl-F5, I get this error: 除此之外,当我使用Ctrl-F5运行代码时,还会收到此错误:

Description:
      Stopped working

Problem signature:
Problem Event Name: CLR20r3
Problem Signature 01:   spvmain.exe
Problem Signature 02:   1.0.0.0
Problem Signature 03:   53840363
Problem Signature 04:   SPVMain
Problem Signature 05:   1.0.0.0
Problem Signature 06:   53840363
Problem Signature 07:   d
Problem Signature 08:   16
Problem Signature 09:   System.IO.FileNotFoundException
OS Version: 6.1.7600.2.0.0.768.2
Locale ID:  1033`

I have installed VMWare and run the code in 32-bit also, but it didnt work. 我已经安装了VMWare并也在32位中运行了代码,但是没有用。 There is no error hwen I run the single file. 我运行单个文件没有错误。 When I tried to run the whole application I get this error. 当我尝试运行整个应用程序时,出现此错误。 How do I solve it? 我该如何解决?

Try to debug the problem in steps: 尝试按以下步骤调试问题:

  1. Does you c++ integrate well with a console application? 您是否将c ++与控制台应用程序很好地集成在一起? (without the UI) (没有用户界面)
  2. Does the UI work ok without the c++ code? 如果没有c ++代码,UI是否可以正常工作?
  3. Can they work together? 他们可以一起工作吗?

That error means there is a DLL it is looking for but it can not find. 该错误意味着有一个正在寻找的DLL,但找不到。 There are two ways I know of to track this issue down. 我知道有两种方法可以跟踪此问题。

First option, edit your program to display what assembly is trying to be loaded, you will see the name of any DLL that was attempted to be loaded but failed. 第一种选择,编辑程序以显示要加载的程序集,您将看到任何试图加载但失败的DLL的名称。

    static void Main(string[] args)
    {
        AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
        Application.Run(new Form1());
    }

    private static System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
    {
        Debug.WriteLine("Trying to resolve:" + args.Name);
        return null;
    }

The other option is enable the Assembly Binding Log via fuslogvw . 另一个选项是通过fuslogvw启用程序集绑定日志。 Open the program as administrator and go to the setting button, set the option to "Log Bind Failures" and set the logging path to some place you can find later to clean up. 以管理员身份打开程序,然后转到设置按钮,将选项设置为“ Log Bind Failures”,并将日志记录路径设置为以后可以清除的某个位置。

在此处输入图片说明

Once you do that, run your program and make it error out, hit the refresh button, then you can view the log files that where generated and see which assembly asked for what and where it looked for that failed load. 完成此操作后,运行程序并使其出错,单击“刷新”按钮,然后您可以查看在何处生成的日志文件,并查看哪个程序集询问什么以及查找失败加载的地方。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 未知模块中出现未处理的“System.IO.FileNotFoundException”类型异常 - An unhandled exception of type 'System.IO.FileNotFoundException' occurred in Unknown Module 未知模块中发生类型为“System.IO.FileNotFoundException”的未处理异常“ - An unhandled exception of type 'System.IO.FileNotFoundException' occurred in Unknown Module" “System.IO.FileNotFoundException”类型的未处理异常 - Dll & 远程处理 - An unhandled exception of type 'System.IO.FileNotFoundException' - Dll & remoting Azure - 未处理的异常:System.IO.FileNotFoundException - Azure - Unhandled Exception: System.IO.FileNotFoundException 获取未处理的异常错误:System.IO.FileNotFoundException: - Getting Unhandled exception error: System.IO.FileNotFoundException: mscorlib.dll 中发生类型为“System.IO.FileNotFoundException”的未处理异常 - An unhandled exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll InAirSignature.exe中发生了类型为'System.IO.FileNotFoundException'的未处理异常 - An unhandled exception of type 'System.IO.FileNotFoundException' occurred in InAirSignature.exe C# 使用未知模块中的互操作未处理的“System.IO.FileNotFoundException”加载 Excel 文件 - C# Loading Excel File Using Interop Unhandled 'System.IO.FileNotFoundException' in Unknown Module CloudTableClient.CreateCloudTableClient引发了System.IO.FileNotFoundException类型的异常 - CloudTableClient.CreateCloudTableClient threw an exception of type System.IO.FileNotFoundException 抛出异常:mscorlib.dll,Visual Studio C# 中的“System.IO.FileNotFoundException” - Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll, Visual studio C#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM