0

トップレベルを追加するWPFアプリケーションがあり、すべてのエラー処理をキャッチします。DispatcherUnhandledException イベントを次のように処理します。

    private void App_OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
    {
        if (_isHandlingError)
        {
            _log.Error("Critical unhandled error", e.Exception);
            e.Handled = true;
            return;
        }

        _isHandlingError = true;
        var vm = _windsorContainer.Resolve<ErrorReporterViewModel>();

        Dispatcher.Invoke(() =>
        {
            vm.Details = FailureMessageBuilder.CreateContent(e.Exception);
            var view = new ErrorReporterView { DataContext = vm };

            view.Show();
        });

        e.Handled = true;

        NotifyOfException(e.Exception, vm.Description);

        _isHandlingError = false;
    }

問題は、Show() (または ShowDialog) の呼び出しが返されず、エラー ダイアログが表示されないことです。

問題は何ですか?

4

1 に答える 1

0

イベントをアプリケーションに添付しましたか?

cApp.Dispatcher.UnhandledException += new DispatcherUnhandledExceptionEventHandler(Dispatcher_UnhandledException);
                cApp.InitializeComponent();
                cApp.Run(new MainWindow());

その後

private static void Dispatcher_UnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
        {
...e.Exception.Message
}
于 2013-08-16T13:45:03.357 に答える