Created
December 27, 2016 09:26
-
-
Save constructor-igor/584763b19fb60bd980cfe3d2a848e376 to your computer and use it in GitHub Desktop.
UnhandledException in WPF
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Dispatcher.CurrentDispatcher.UnhandledException += CurrentDispatcher_UnhandledException; | |
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; | |
[HandleProcessCorruptedStateExceptions] | |
[SecurityCritical] | |
void CurrentDispatcher_UnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) | |
{ | |
var ex = e.Exception; | |
string message = ex.NameAndMessage(); | |
string details = ex.GetDetailedMessage(); | |
string title = "Unhandled exception in GUI dispatcher thread"; | |
e.Handled = true; | |
} | |
[HandleProcessCorruptedStateExceptions] | |
[SecurityCritical] | |
void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) | |
{ | |
var ex = e.ExceptionObject as Exception; | |
var message = ex.NameAndMessage(); | |
Environment.FailFast(ex.NameAndMessage()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment