static void Main()
{
try
{
//处理未捕获的异常
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
//处理UI线程异常
Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
//处理非UI线程异常
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
catch (Exception ex)
{
string str = GetExceptionMsg(ex,string.Empty);
MessageBox.Show(str, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
{
//记录执行信息
//Log log = new Log(@"D:\新建文件夹 (3)");
string str = GetExceptionMsg(e.Exception, e.ToString());
string write_log = GetExceptionWriteToLog(e.Exception, e.ToString());
//log.Logerrorset(write_log);
MessageBox.Show(str, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余2页未读,立即下载