【发布时间】:2020-09-11 16:45:38
【问题描述】:
您好,我在 Visual Studio 专业版上设置应用时遇到问题。获取代码完成后,我单击该应用程序,但弹出消息,例如您的应用程序中发生了未处理的异常。我的框架是 .NET Framework 4.5,我下载了 MySQL 连接器 6.9.9 版本。而且不知道是不是我的64位版本的windows 10 pro或者框架和MySQL连接器设置错误。
错误信息说:
有关调用的详细信息,请参阅此消息的末尾 即时 (JIT) 调试,而不是此对话框。
**************异常文本**************
System.ComponentModel.Win32Exception (0x80004005): The system cannot find the file specified
at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start(String fileName)
at superpos3.Main.pictureBox2_Click(Object sender, EventArgs e) in
D:\superpos3\superpos3\superpos3\Main.cs:line 22
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.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.8.4180.0 built by: NET48REL1LAST_B
CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
----------------------------------------
superpos3
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///D:/superpos3/superpos3/superpos3/bin/Debug/superpos3.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 4.0.0.0
Win32 Version: 4.8.4150.0 built by: NET48REL1LAST_C
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.8.4001.0 built by: NET48REL1LAST_C
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.8.3752.0 built by: NET48REL1
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.8.3752.0 built by: NET48REL1
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.8.4180.0 built by: NET48REL1LAST_B
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.8.3752.0 built by: NET48REL1
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
MySql.Data
Assembly Version: 6.9.9.0
Win32 Version: 6.9.9.0
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/MySql.Data/v4.0_6.9.9.0__c5687fc88969c44d/MySql.Data.dll
----------------------------------------
System.Data
Assembly Version: 4.0.0.0
Win32 Version: 4.8.4121.0 built by: NET48REL1LAST_C
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.Data/v4.0_4.0.0.0__b77a5c561934e089/System.Data.dll
----------------------------------------
System.Transactions
Assembly Version: 4.0.0.0
Win32 Version: 4.8.3752.0 built by: NET48REL1
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.Transactions/v4.0_4.0.0.0__b77a5c561934e089/System.Transactions.dll
----------------------------------------
System.EnterpriseServices
Assembly Version: 4.0.0.0
Win32 Version: 4.8.3752.0 built by: NET48REL1
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.EnterpriseServices/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.EnterpriseServices.dll
----------------------------------------
System.Management
Assembly Version: 4.0.0.0
Win32 Version: 4.8.3752.0 built by: NET48REL1
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Management/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Management.dll
----------------------------------------
System.Numerics
Assembly Version: 4.0.0.0
Win32 Version: 4.8.3752.0 built by: NET48REL1
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Numerics/v4.0_4.0.0.0__b77a5c561934e089/System.Numerics.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>
启用 JIT 调试后,任何未处理的异常 将发送到计算机上注册的 JIT 调试器 而不是被这个对话框处理。
我在这里添加好了...
main.cs,第 22 行就是这段代码:System.Diagnostics.Process.Start("Word");
当我在 Main.cs[Design] 表单上单击我的 Microsoft Word 应用程序时,出现了错误。我认为错误来自 MySQL 连接器 6.9.9 和框架 4.5。
我从程序集中添加了 MySQL 连接器 net 6.9.9 文件夹的这些文件中的引用:
Mysql.Data.dll
Mysql.Data.Entity.dll
MySql.Data.Entity.EF6.dll
Mysql.Fabric.Plugin.dll
Mysql.Web.dll
The codes in Main.cs is:
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;
namespace superpos3
{
public partial class Main : Form
{
public Main()
{
InitializeComponent();
}
private void pictureBox2_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("Word");
}
private void pictureBox3_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("Excel");
}
private void pictureBox4_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("PowerPoint");
}
private void pictureBox5_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("Access");
}
private void pictureBox6_Click(object sender, EventArgs e)
{
DialogResult result = MessageBox.Show("Windows is going to shut down. Are you sure?", "Please confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{
System.Diagnostics.Process.Start("shutdown", "/s /t 0");
}
}
private void pictureBox7_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("NotePad");
}
private void pictureBox8_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("Calculator");
}
private void pictureBox11_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("Google Chrome");
}
private void pictureBox10_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("Internet Explorer");
}
private void pictureBox9_Click(object sender, EventArgs e)
{
DialogResult result = MessageBox.Show("Windows is going to restart. Are you sure?", "Please confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{
System.Diagnostics.Process.Start("shutdown", "/r /t 0");
}
}
}
}
【问题讨论】:
-
很明显一个文件丢失了。 Main.cs 第 22 行中的代码是什么?
-
请粘贴您的代码。
-
请看下面的答案
-
不要将其添加为答案,而是edit您的问题。
标签: c# .net visual-studio error-handling