标签:在线 cep src current 程序 wpf ati for isp
1 static void Main(string[] args) 2 { 3 AppDomain.CurrentDomain.UnhandledException +=new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); 4 } 5 6 static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) 7 { 8 Exception error = (Exception)e.ExceptionObject; 9 Console.WriteLine("MyHandler caught : "+ error.Message); 10 }
1 [STAThread] 2 static void Main() 3 { 4 Application.ThreadException +=new ThreadExceptionEventHandler(UIThreadException); 5 } 6 7 private static void UIThreadException(object sender, ThreadExceptionEventArgs t) 8 { 9 try 10 { 11 string errorMsg ="Windows窗体线程异常 : \n\n"; 12 MessageBox.Show(errorMsg + t.Exception.Message + Environment.NewLine + t.Exception.StackTrace); 13 } 14 catch 15 { 16 MessageBox.Show("不可恢复的Windows窗体异常,应用程序将退出!"); 17 } 18 }
1 代码 2 3 public App() 4 { 5 this.DispatcherUnhandledException +=new DispatcherUnhandledExceptionEventHandler(Application_DispatcherUnhandledException); 6 AppDomain.CurrentDomain.UnhandledException +=new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); 7 } 8 9 void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) 10 { 11 try 12 { 13 Exception ex = e.ExceptionObject as Exception; 14 string errorMsg ="非WPF窗体线程异常 : \n\n"; 15 MessageBox.Show(errorMsg + ex.Message + Environment.NewLine + ex.StackTrace); 16 } 17 catch 18 { 19 MessageBox.Show("不可恢复的WPF窗体线程异常,应用程序将退出!"); 20 } 21 } 22 23 privatevoid Application_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) 24 { 25 try 26 { 27 Exception ex = e.Exception; 28 string errorMsg ="WPF窗体线程异常 : \n\n"; 29 MessageBox.Show(errorMsg + ex.Message + Environment.NewLine + ex.StackTrace); 30 } 31 catch 32 { 33 MessageBox.Show("不可恢复的WPF窗体线程异常,应用程序将退出!"); 34 } 35 }
标签:在线 cep src current 程序 wpf ati for isp
原文地址:https://www.cnblogs.com/wyp1988/p/9928636.html