2

既存の Winforms ベースのアプリケーションを WPF に移行しています。

Winforms アプリのアプリケーション レベルで未処理の例外を処理するために、次のことを行いました。

Application.ThreadException
    += new ThreadExceptionEventHandler(Application_ThreadException);     

AppDomain.CurrentDomain.UnhandledException
    += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);   

Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);

WPF ベースのアプリケーションでこれらの条件を処理するにはどうすればよいですか?

4

1 に答える 1

3

DispatcherUnhandledExceptionApplication の現在のインスタンスのイベントを処理できます。

Application.Current.DispatcherUnhandledException += (s,e) => {...};
于 2013-10-20T15:57:30.840 に答える