[WPF]使用DispatcherUnhandledException捕捉未经处理的异常

2022-10-27,,,

使用DispatcherUnhandledException捕捉未经处理的异常

using System.Windows;

namespace Test02
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e); this.DispatcherUnhandledException += App_DispatcherUnhandledException;
} void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
{
MessageBox.Show(e.Exception.Message);
}
}
}

  

[WPF]使用DispatcherUnhandledException捕捉未经处理的异常的相关教程结束。

《[WPF]使用DispatcherUnhandledException捕捉未经处理的异常.doc》

下载本文的Word格式文档,以方便收藏与打印。