/// <summary> /// Non-UI Thread expection handler. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The UnhandledExceptionEventArgs. /// </param> private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { if (e.ExceptionObject.GetType() == typeof(FileNotFoundException)) { GeneralApplicationException exception = new GeneralApplicationException("A file appears to be missing.", "Try re-installing Microsoft .NET Framework 4.0", (Exception)e.ExceptionObject); this.ShowError(exception); } else { this.ShowError(e.ExceptionObject); } }
/// <summary> /// Handle unhandled exceptions. UI thread only. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The DispatcherUnhandledExceptionEventArgs. /// </param> private void Dispatcher_UnhandledException( object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) { if (e.Exception.GetType() == typeof(FileNotFoundException)) { GeneralApplicationException exception = new GeneralApplicationException("A file appears to be missing.", "Try re-installing Microsoft .NET Framework 4.0", e.Exception); this.ShowError(exception); } else if (e.Exception.GetType() == typeof(GeneralApplicationException)) { this.ShowError(e.Exception); } else if (e.Exception.InnerException != null && e.Exception.InnerException.GetType() == typeof(GeneralApplicationException)) { this.ShowError(e.Exception.InnerException); } else { this.ShowError(e.Exception); } e.Handled = true; }
/// <summary> /// Handle unhandled exceptions. UI thread only. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The DispatcherUnhandledExceptionEventArgs. /// </param> private void Dispatcher_UnhandledException( object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) { if (e.Exception.GetType() == typeof(FileNotFoundException)) { GeneralApplicationException exception = new GeneralApplicationException("A file appears to be missing.", "Try re-installing Microsoft .NET Framework 4.0", e.Exception); this.ShowError(exception); } else if (e.Exception.GetType() == typeof(GeneralApplicationException)) { this.ShowError(e.Exception); } else if (e.Exception.InnerException != null && e.Exception.InnerException.GetType() == typeof(GeneralApplicationException)) { this.ShowError(e.Exception.InnerException); } else if (e.Exception.InnerException != null && e.Exception.InnerException.GetType() == typeof(Castle.MicroKernel.ComponentActivator.ComponentActivatorException)) { // Handle Component Activation Exceptions. Can happen when one of the services throws an execption when being constructed. Exception innerException = e.Exception.InnerException.InnerException; if (innerException != null && innerException.InnerException != null && innerException.InnerException.GetType() == typeof(GeneralApplicationException)) { this.ShowError(innerException.InnerException); } else { this.ShowError(innerException); } } else { this.ShowError(e.Exception); } e.Handled = true; }