I have a WPF application that\'s crashing once I get it onto machines that do not have a development environment installed-- if this is a dupe, I\'m welcome to closing, but
The procedure I would use is to handle the UnhandledException
event in the app domain.
Once you have done that, you have a number of options. Logging the exception to a file, serialising it for later inspection, showing a dialog box with the exception message.
EDIT: XamlParseException
's occur when your main window is being created. This means that the constructor of that window is being called. If you perform any logic in that constructor, any resulting exceptions will throw a XamlParseException
. It is my understanding that the UnhandledException
handler will still catch this exception.
To hook up the UnhandledException
event in WPF, add the event hookup in your app.xaml
which then adds a method in your app.cs
public partial class App : Application
{
void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
{
// Process unhandled exception do stuff below
// Prevent default unhandled exception processing
e.Handled = true;
}
}
MSDN