Home > WPF > Application Exeption Handling in WPF

Application Exeption Handling in WPF

DispatcherUnhandledException in Application.XAML.CS can be used to catch all unhandled exceptions. The following is a sample source codes:

private void App_DispatcherUnhandledException(object sender,
DispatcherUnhandledExceptionEventArgs e)
{
MessageBox.Show(“An unhandled ” + e.Exception.GetType().ToString() +
” exception was caught and ignored.”);
e.Handled = true;
}

And the event can be wired up as:

<Application x:Class=”PreventSessionEnd.App”
xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation&#8221;
xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml&#8221;
StartupUri=”Window1.xaml”
DispatcherUnhandledException=”App_DispatcherUnhandledException”>
</Application>

Advertisements
Categories: WPF
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: