WPF DispatcherUnhandledException 异常捕获最后的大门
这里在界面按钮事件下除 0 测试,感觉软件还是退出了?
/// <summary>
/// App.xaml 的交互逻辑
/// </summary>
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
DispatcherUnhandledException += App_DispatcherUnhandledException;
}
private void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
{
//throw new NotImplementedException();
MessageBox.Show(e.Exception.Message + "---" + e.ToString());
}
}
浙公网安备 33010602011771号