异常处理
异常处理
- app.xaml中加入
1 DispatcherUnhandledException="Application_DispatcherUnhandledException"

2.app.xaml.cs 代码
1 private void Application_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) 2 { 3 //e.Handled = true; 当程序执行出现位置错误,会报错,不会自动停止运行。 4 MessageBox.Show("程序出现未知错误,请联系管理员:" + e.Exception.Message); 5 e.Handled = true; 6 }
浙公网安备 33010602011771号