捕获未处理异常
This commit is contained in:
@@ -21,6 +21,8 @@ namespace GeekDesk
|
||||
public App()
|
||||
{
|
||||
this.Startup += new StartupEventHandler(App_Startup);
|
||||
Application.Current.DispatcherUnhandledException += Current_DispatcherUnhandledException;
|
||||
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
||||
}
|
||||
|
||||
private void App_Startup(object sender, StartupEventArgs e)
|
||||
@@ -42,6 +44,7 @@ namespace GeekDesk
|
||||
{
|
||||
e.Handled = true;//使用这一行代码告诉运行时,该异常被处理了,不再作为UnhandledException抛出了。
|
||||
LogUtil.WriteErrorLog(e, "未捕获异常!");
|
||||
MessageBox.Show("GeekDesk遇到一个问题, 不用担心, 这不影响其它操作!");
|
||||
}
|
||||
|
||||
void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
|
||||
|
||||
Reference in New Issue
Block a user