C# 运行环境问题处理

同事的电脑运行程序,莫名其妙的闪退。

增加以下代码查找原因。

using System;

using System.Collections.Generic;

using System.Linq;

using System.Threading.Tasks;

using System.Windows.Forms;

 
 

namespace WindowsFormsApplication6

{

static
class
Program

{

///
<summary>

///
应用程序的主入口点。

///
</summary>

[STAThread]

static
void Main()

{

AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

Application.EnableVisualStyles();

Application.SetCompatibleTextRenderingDefault(false);

Application.Run(new
Form1());

}

 
 

private
static
void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)

{

MessageBox.Show(e.ExceptionObject.ToString());

}

}

}

 
 

 
 

  

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注