WPF 应用程序捕获异常
public partial class App : Application { public App() { this.DispatcherUnhandledException += App_DispatcherUnhandledException; } private void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) { // 记录异常信息 e.Handled = true; // 通知WPF已处理异常 } }