public App()
{
//UI執行緒例外
this.DispatcherUnhandledException += App_DispatcherUnhandledException;
//非UI執行緒例外
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
}
private void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
{
//可以記錄日志并轉向錯誤bug視窗友好提示用戶
e.Handled = true;
Notice.Show("抱歉給您帶來不便!訊息:" + e.Exception.Message, "系統錯誤", MessageBoxIcon.Error);
}
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
//可以記錄日志并轉向錯誤bug視窗友好提示用戶
if (e.ExceptionObject is System.Exception)
{
Exception ex = (System.Exception)e.ExceptionObject;
Notice.Show("抱歉給您帶來不便!訊息:" + ex.Message,"系統錯誤",MessageBoxIcon.Error);
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/1733.html
標籤:WPF
上一篇:Winform中實作ZedGraph滾輪縮放后自動重新加載資料
下一篇:WPF call global variable via App.Current.Properties[ObjKey]=ObjValue
