|
@@ -8,10 +8,36 @@ namespace QuickPDF2JPG
|
|
|
[STAThread]
|
|
[STAThread]
|
|
|
static void Main()
|
|
static void Main()
|
|
|
{
|
|
{
|
|
|
|
|
+ // 注册全局异常捕获事件
|
|
|
|
|
+ Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
|
|
|
|
|
+ AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
|
|
|
|
|
+
|
|
|
// To customize application configuration such as set high DPI settings or default font,
|
|
// To customize application configuration such as set high DPI settings or default font,
|
|
|
// see https://aka.ms/applicationconfiguration.
|
|
// see https://aka.ms/applicationconfiguration.
|
|
|
ApplicationConfiguration.Initialize();
|
|
ApplicationConfiguration.Initialize();
|
|
|
Application.Run(new frmMain());
|
|
Application.Run(new frmMain());
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ // 处理未捕获的异常并记录日志
|
|
|
|
|
+ private static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e) {
|
|
|
|
|
+ // 处理异常,如记录日志、显示错误消息等
|
|
|
|
|
+ Exception exception = e.Exception;
|
|
|
|
|
+ // ToDo: 处理异常的逻辑代码
|
|
|
|
|
+
|
|
|
|
|
+ // 关闭应用程序或显示错误信息
|
|
|
|
|
+ // Application.Exit();
|
|
|
|
|
+ MessageBox.Show("发生错误:" + exception.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 处理未捕获的异常并记录日志
|
|
|
|
|
+ private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) {
|
|
|
|
|
+ // 处理异常,如记录日志、显示错误消息等
|
|
|
|
|
+ Exception exception = e.ExceptionObject as Exception;
|
|
|
|
|
+ // ToDo: 处理异常的逻辑代码
|
|
|
|
|
+
|
|
|
|
|
+ // 关闭应用程序或显示错误信息
|
|
|
|
|
+ // Application.Exit();
|
|
|
|
|
+ MessageBox.Show("发生错误:" + exception.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|