Friday, 16 August 2013

Trying to showing a dialog on DispatcherUnhandledException

Trying to showing a dialog on DispatcherUnhandledException

I have a WPF application into which I'm adding some top level, catch all
error handling. I handle the DispatcherUnhandledException event like so:
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;
}
The problem is, that the call to Show() (or ShowDialog) never returns, and
the error dialog is never shown.
What might be the issue?

No comments:

Post a Comment