SEToolbox.App.OnDispatcherUnhandledException C# (CSharp) Méthode

OnDispatcherUnhandledException() private méthode

private OnDispatcherUnhandledException ( object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e ) : void
sender object
e System.Windows.Threading.DispatcherUnhandledExceptionEventArgs
Résultat void
        private void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
        {
            var comException = e.Exception as System.Runtime.InteropServices.COMException;

            if (comException != null && comException.ErrorCode == -2147221040)
            {
                // To fix 'OpenClipboard Failed (Exception from HRESULT: 0x800401D0 (CLIPBRD_E_CANT_OPEN)'
                // http://stackoverflow.com/questions/12769264/openclipboard-failed-when-copy-pasting-data-from-wpf-datagrid

                e.Handled = true;
                return;
            }

            // Log details to Application Event Log.
            DiagnosticsLogging.LogException(e.Exception);

            string message;

            if (e.Exception is ToolboxException)
            {
                message = e.Exception.Message;
            }
            else
            {
                // Unhandled Exception.
                if (DiagnosticsLogging.LoggingSourceExists())
                    message = string.Format(Res.DialogUnhandledExceptionEventMessage, e.Exception.Message);
                else
                    message = string.Format(Res.DialogUnhandledExceptionMessage, e.Exception.Message);
            }

            MessageBox.Show(message, string.Format(Res.DialogUnhandledExceptionTitle, GlobalSettings.GetAppVersion()), MessageBoxButton.OK, MessageBoxImage.Error);

            TempfileUtil.Dispose();

            e.Handled = true;

            if (Application.Current != null)
            {
                Application.Current.Shutdown();
            }
        }