Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// <summary>
- /// Interaction logic for App.xaml
- /// </summary>
- public partial class App:Application {
- void Application_Startup(object sender,StartupEventArgs e) {
- AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
- }
- private void Application_DispatcherUnhandledException(object sender,System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) {
- try {
- MessageBox.Show(e.Exception.Message,
- "Un expected error",
- MessageBoxButton.OK,
- MessageBoxImage.Error);
- }
- finally {
- e.Handled = true;
- }
- }
- void CurrentDomain_UnhandledException(object sender,UnhandledExceptionEventArgs e) {
- if(e.IsTerminating)
- return;
- string msg = "Unknown error";
- Exception ex = e.ExceptionObject as Exception;
- if(ex != null)
- msg = ex.Message;
- MessageBox.Show(msg,"Un expected error",
- MessageBoxButton.OK,MessageBoxImage.Error);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment