Visual Studio C#路径文件中的错误 [英] Error in Visual Studio C# path file

查看:104
本文介绍了Visual Studio C#路径文件中的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

地狱:

Hell :

这是mY错误 

This is mY Error 

有关调用 

just的详细信息,请参阅此消息的结尾-in-time(JIT)调试而不是此对话框。



**************异常文本**************

System.IO.FileNotFoundException:C:\ Users\AbduAllah \documents \ visual studio 2015 \\ Project \ TestRun \TestRun \bin \Debug \PersonData.exe

    at System.Drawing.Icon.ExtractAssociatedIcon(String filePath,Int32 index)

    at System.Drawing.Icon.ExtractAssociatedIcon(String filePath)

    at PersonData.frmPerson.frmPerson_Load(Object sender,EventArgs e)

   在System.Windows.Forms.Form.OnLoad(EventArgs e)

   在System.Windows.Forms.Form.OnCreateControl()

   在System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)

   在System.Windows.Forms.Control.CreateControl()

    at System.Windows.Forms.Control.WmShowWindow(Message& m)

    at System.Windows.Forms.Control.WndProc(Message& m)

    at System.Windows.Forms.ScrollableControl.WndProc(Message& m)

    at System.Windows.Forms.ContainerControl.WndProc(Message& m)

   在System.Windows.Forms.Form.WmShowWindow(消息& m)

    at System.Windows.Forms.Form.WndProc(Message& m)

    at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)

    at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)

   在System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd,Int32 msg,IntPtr wparam,IntPtr lparam)





**************已加载的装配**************

mscorlib

   汇编版本:4.0.0.0

    Win32版本:4.7.3131.0内容:NET472REL1LAST

    CodeBase:file:/// C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll

-------------- --------------------------

PersonData

  ;  汇编版本:1.0.0.0

    Win32版本:1.0.0.0

    CodeBase:file:/// D:/Test%20App/Test%20Run/PersonData.exe

------------------ ----------------------

System.Windows.Forms

  ;  汇编版本:4.0.0.0

    Win32版本:4.7.3056.0内容:NET472REL1

----------------------------------------

系统

   汇编版本:4.0.0.0

    Win32版本:4.7.3056.0内容:NET472REL1

------ ----------------------------------

System.Drawing

   汇编版本:4.0.0.0

    Win32版本:4.7.3056.0内容:NET472REL1

- --------------------------------------

系统.Configuration

   汇编版本:4.0.0.0

    Win32版本:4.7.3056.0内容:NET472REL1

- --------------------------------------

系统.Core

   汇编版本:4.0.0.0

    Win32版本:4.7.3110.0内容:NET472REL1LAST_C

    CodeBase:file:/// C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll

- --------------------------------------

系统.Xml

   汇编版本:4.0.0.0

    Win32版本:4.7.3056.0内容:NET472REL1

- --------------------------------------

辅助功能

   汇编版本:4.0.0.0

    Win32版本:4.7.3056.0内容:NET472REL1

------ ----------------------------------



************** JIT调试**************

启用-in-time(JIT)调试,此

应用程序或计算机(machine.config)的.config文件必须具有

jitDebugging值在system.windows.forms部分中设置。

应用程序也必须使用调试

>
启用。

例如:



< configuration>

  &NBSP; < system.windows.forms jitDebugging =" true" />

< / configuration>



启用JIT调试时,任何未处理的异常

将被发送到计算机上注册的JIT调试器

,而不是由此对话框处理。



See the end of this message for details on invoking 
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.IO.FileNotFoundException: C:\Users\AbduAllah\documents\visual studio 2015\Projects\TestRun\TestRun\bin\Debug\PersonData.exe
   at System.Drawing.Icon.ExtractAssociatedIcon(String filePath, Int32 index)
   at System.Drawing.Icon.ExtractAssociatedIcon(String filePath)
   at PersonData.frmPerson.frmPerson_Load(Object sender, EventArgs e)
   at System.Windows.Forms.Form.OnLoad(EventArgs e)
   at System.Windows.Forms.Form.OnCreateControl()
   at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
   at System.Windows.Forms.Control.CreateControl()
   at System.Windows.Forms.Control.WmShowWindow(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.ContainerControl.WndProc(Message& m)
   at System.Windows.Forms.Form.WmShowWindow(Message& m)
   at System.Windows.Forms.Form.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
    Assembly Version: 4.0.0.0
    Win32 Version: 4.7.3131.0 built by: NET472REL1LAST
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
----------------------------------------
PersonData
    Assembly Version: 1.0.0.0
    Win32 Version: 1.0.0.0
    CodeBase: file:///D:/Test%20App/Test%20Run/PersonData.exe
----------------------------------------
System.Windows.Forms
    Assembly Version: 4.0.0.0
    Win32 Version: 4.7.3056.0 built by: NET472REL1
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
    Assembly Version: 4.0.0.0
    Win32 Version: 4.7.3056.0 built by: NET472REL1
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
    Assembly Version: 4.0.0.0
    Win32 Version: 4.7.3056.0 built by: NET472REL1
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Configuration
    Assembly Version: 4.0.0.0
    Win32 Version: 4.7.3056.0 built by: NET472REL1
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Core
    Assembly Version: 4.0.0.0
    Win32 Version: 4.7.3110.0 built by: NET472REL1LAST_C
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
----------------------------------------
System.Xml
    Assembly Version: 4.0.0.0
    Win32 Version: 4.7.3056.0 built by: NET472REL1
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
Accessibility
    Assembly Version: 4.0.0.0
    Win32 Version: 4.7.3056.0 built by: NET472REL1
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/Accessibility/v4.0_4.0.0.0__b03f5f7f11d50a3a/Accessibility.dll
----------------------------------------

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
    <system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.

这是我的代码:

使用System;

使用System.Collections.Generic;

使用System。 ComponentModel;

使用System.Drawing;

使用System.Linq;

使用System.Text;

使用System.Threading.Tasks;

使用System.Windows。表格;

使用System.Threading;

使用System.Runtime。 InteropServices;



命名空间TestRun

{<圣彼得堡yle ="">
  &NBSP; public partial class frmRun:Form

  &NBSP; {

  &NBSP; &NBSP; &NBSP; public frmRun()

  &NBSP; &NBSP; &NBSP; {

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; InitializeComponent();

  &NBSP; &NBSP; &NBSP; }



  &NBSP; &NBSP;   



  &NBSP; &NBSP; &NBSP; private void btnExit_Click(object sender,EventArgs e)

  &NBSP; &NBSP; &NBSP; {

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; this.Close();

  &NBSP; &NBSP; &NBSP; }



  &NBSP; &NBSP; &NBSP; private void btnPersonData_Click(object sender,EventArgs e)

  &NBSP; &NBSP; &NBSP; {

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Process.Start(@"D:\ Test App \ Test Run \ PersonData.exe");

  &NBSP; &NBSP; &NBSP; }

}

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Diagnostics;
using System.Threading;
using System.Runtime.InteropServices;


namespace TestRun
{
    public partial class frmRun : Form
    {
        public frmRun()
        {
            InitializeComponent();
        }

        

        private void btnExit_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnPersonData_Click(object sender, EventArgs e)
        {
            Process.Start(@"D:\Test App\Test Run\PersonData.exe");
        }
    }
}

我想从其他目录运行一个Exe文件,但我的应用程序中出现未处理的异常.net framework c# 

I want to Run an Exe file from a different Directory but I get unhandled exception has occurred in your application .net framework c# 

推荐答案

您是否注意到确切的错误,找不到文件。在执行Process.Start之前使用断言。

Did you notice the exact error, file not found. Before executing Process.Start use assertion.

var fileName = @"D:\Test App\Test Run\PersonData.exe"; 
if (File.Exists(fileName))
{
    Process.Start(fileName);
}


这篇关于Visual Studio C#路径文件中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆