Exemple #1
0
        private static void AppDispatcherUnhandledExceptionEventHandler(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
        {
            MessageBox.Show(e.ToString(), "发生异常", MessageBoxButton.OK, MessageBoxImage.Error);

            string logName = "UnhandledException.log";

            if (File.Exists(logName))
            {
                string oldFile = File.ReadAllText(logName);
                File.WriteAllText(logName,
                                  oldFile
                                  + Environment.NewLine + Environment.NewLine
                                  + DateTime.Now.ToString()
                                  + Environment.NewLine
                                  + e.Exception.ToString());
            }
            else
            {
                File.WriteAllText(logName,
                                  DateTime.Now.ToString()
                                  + Environment.NewLine
                                  + e.Exception.ToString());
            }
            Current.Shutdown();
            return;
        }
        void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
        {
            // if the code crashed trying to handle it once chances are it will just crash again
            if (handling_exception)
            {
                Environment.FailFast("Exception occured file processing an exception", e.Exception);
            }
            handling_exception = true;
            if (e.Exception is UnauthorizedAccessException)
            {
                e.Handled          = true;
                handling_exception = false;
                MessageBox.Show(e.ToString(), "Permission denied!");
            }

            if (e.Exception is ToolkitInterface.ToolkitBase.MissingFile)
            {
                e.Handled          = true;
                handling_exception = false;
                var missing_file_excep = e.Exception as ToolkitBase.MissingFile;
                MessageBox.Show("The following executable is missing: " + missing_file_excep.FileName, "Corrupt Install");
            }
            else
            {
                MessageBoxResult result = MessageBox.Show(e.Exception.ToString(), "An unhandled exception has occurred!", MessageBoxButton.OKCancel);
                if (result == MessageBoxResult.OK)
                {
                    e.Handled = true;
                }
            }
            handling_exception = false;
        }
        private static void OnDispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
        {
            Debug.WriteLine(e.ToString());
            string message = e.Exception.Message + Environment.NewLine + Environment.NewLine + e.ToString();
            string title   = e.Exception.HResult.ToString();


            MessageBox.Show(message, title, MessageBoxButton.OK, MessageBoxImage.Error);
        }
Exemple #4
0
 void Application_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
 {
     using (StreamWriter sw = File.AppendText(@"UnhandledErrors.log"))
     {
         sw.WriteLine(String.Format("[{0}]", DateTime.Now.ToString("g")));
         sw.WriteLine(String.Format("[EventArgs] {0}", e.ToString()));
         sw.WriteLine(String.Format("[Exception] {0}", e.Exception.ToString()));
         sw.WriteLine(String.Format("[Dispatcher] {0}", e.Dispatcher.ToString()));
         sw.WriteLine(String.Format("[Sender] {0}", sender.ToString()) + Environment.NewLine);
     }
 }
Exemple #5
0
        private void Application_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
        {
            if (_hasError)
            {
                return;
            }

            _hasError = true;

            if (e.Exception is OutOfMemoryException)
            {
                MessageBox.Show("Недостаточно памяти для выполнения программы!", ProductName, MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else if (e.Exception is Win32Exception || e.Exception is NotImplementedException || e.Exception.ToString().Contains("VerifyNotClosing"))
            {
                if (e.Exception.Message != "Параметр задан неверно")
                {
                    MessageBox.Show(string.Format("Ошибка выполнения программы: {0}!", e.Exception.Message), ProductName, MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            else if (e.Exception is InvalidOperationException && e.Exception.Message.Contains("Идет завершение работы объекта Application"))
            {
                // Это нормально, ничего не сделаешь
            }
            else if (e.Exception is BadImageFormatException)
            {
                MessageBox.Show(string.Format("Ошибка запуска программы: {0}!", e.Exception.Message), ProductName, MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else if (e.Exception.ToString().Contains("MediaPlayerState.OpenMedia"))
            {
                MessageBox.Show(string.Format("Некорректный адрес мультимедиа. Программа аварийно завершена с ошибкой: {0}!", e.Exception.Message), ProductName, MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else if (e.Exception is COMException || e.Exception.ToString().Contains("UpdateTaskbarProgressState") || e.Exception.ToString().Contains("FindNameInTemplateContent"))
            {
                MessageBox.Show(string.Format("Ошибка выполнения программы: {0}!", e.ToString()), ProductName, MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else if (e.Exception.ToString().Contains("MahApps.Metro"))
            {
                // Ничего не сделаешь
            }
            else if (e.Exception is InvalidOperationException invalidOperationException &&
                     (invalidOperationException.Message.Contains("Невозможно выполнить эту операцию, когда привязка отсоединена") ||
                      invalidOperationException.Message.Contains("Cannot perform this operation when binding is detached")))
            {
                MessageBox.Show(invalidOperationException.Message, ProductName, MessageBoxButton.OK, MessageBoxImage.Error);
            }
Exemple #6
0
 private void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
 {
     MessageBox.Show("Erreur non traitée :" + e.ToString());
     e.Handled = true;
 }
Exemple #7
0
 private void Current_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
 {
     Debug.Print("Unhandled exception: " + e.ToString());
 }
Exemple #8
0
 private void Current_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
 {
     MessageBox.Show(e.ToString(), "Unhandled Error", MessageBoxButton.OK, MessageBoxImage.Error);
 }
Exemple #9
0
 private void Application_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
 {
     MessageBox.Show(e.ToString());
 }
Exemple #10
0
 private void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
 {
     Logging.ToLog("App - !!! App_DispatcherUnhandledException: " + e.ToString());
     HandleException(e.Exception);
 }
Exemple #11
0
 private void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
 {
     System.Console.WriteLine(e.ToString());
 }
Exemple #12
0
        void DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
        {
            string errorMessage = "[DispatcherUnhandledException]" + e.ToString();

            ExLogger.ExLog(errorMessage);
        }
Exemple #13
0
 void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
 {
     MessageBox.Show(e.ToString(), "Unhandled Exception - Application Closing", MessageBoxButton.OK, MessageBoxImage.Stop);
     Application.Current.Shutdown();
 }
 private void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
 {
     MessageBox.Show($"Unhandled error: {e.ToString()}");
 }
Exemple #15
0
 private void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
 {
     JryVideo.Core.Log.Write(e.ToString());
 }
Exemple #16
0
 private void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
 {
     MessageBox.Show(e.ToString(), "Unhandled Exception");
     e.Handled = true;
 }
Exemple #17
0
        static void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
        {
            e.Handled = true;

            MessageBox.Show(e.ToString());
        }
Exemple #18
0
 private void Application_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
 {
     MessageBox.Show("Unhandled exception:" + e.Exception.Message + "\n" + e.ToString() + "\n\nPlease contact the developer with these details so they can be fixed.", "Exception", MessageBoxButton.OK, MessageBoxImage.Warning);
     e.Handled = true;
 }
        private void Application_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
        {
            if (_hasError)
            {
                return;
            }

            _hasError = true;

            if (e.Exception is OutOfMemoryException)
            {
                MessageBox.Show("Недостаточно памяти для выполнения программы!", ProductName, MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else if (e.Exception is Win32Exception || e.Exception is NotImplementedException || e.Exception.ToString().Contains("VerifyNotClosing"))
            {
                if (e.Exception.Message != "Параметр задан неверно")
                {
                    MessageBox.Show(string.Format("Ошибка выполнения программы: {0}!", e.Exception.Message), ProductName, MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            else if (e.Exception is InvalidOperationException && e.Exception.Message.Contains("Идет завершение работы объекта Application"))
            {
                // Это нормально, ничего не сделаешь
            }
            else if (e.Exception is BadImageFormatException)
            {
                MessageBox.Show(string.Format("Ошибка запуска программы: {0}!", e.Exception.Message), ProductName, MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else if (e.Exception.ToString().Contains("MediaPlayerState.OpenMedia"))
            {
                MessageBox.Show(string.Format("Некорректный адрес мультимедиа. Программа аварийно завершена с ошибкой: {0}!", e.Exception.Message), ProductName, MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else if (e.Exception is COMException || e.Exception.ToString().Contains("UpdateTaskbarProgressState") || e.Exception.ToString().Contains("FindNameInTemplateContent"))
            {
                MessageBox.Show(string.Format("Ошибка выполнения программы: {0}!", e.ToString()), ProductName, MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else if (e.Exception.ToString().Contains("MahApps.Metro"))
            {
                // Ничего не сделаешь
            }
            else
            {
                var exception     = e.Exception;
                var message       = new StringBuilder();
                var systemMessage = new StringBuilder();
                var version       = Assembly.GetExecutingAssembly().GetName().Version;

                while (exception != null)
                {
                    message.AppendLine(exception.Message).AppendLine();
                    systemMessage.AppendLine(exception.ToString()).AppendLine();
                    exception = exception.InnerException;
                }

                var errorInfo = new ErrorInfo {
                    Time = DateTime.Now, Version = version, Error = systemMessage.ToString()
                };
#if !DEBUG
                if (App.IsVistaOrLater)
                {
                    using (var dialog = new TaskDialog {
                        Caption = App.ProductName, InstructionText = "Серьёзный сбой в приложении. Отправить отчёт автору?", Text = message.ToString().Trim(), Icon = TaskDialogStandardIcon.Warning, StandardButtons = TaskDialogStandardButtons.Ok
                    })
                    {
                        dialog.Show();
                    }
                }
                else
#endif
                {
                    MessageBox.Show($"{SIQuester.Properties.Resources.SendErrorHeader}{Environment.NewLine}{Environment.NewLine}{message.ToString().Trim()}", ProductName, MessageBoxButton.OK, MessageBoxImage.Exclamation);
                }
            }

            e.Handled = true;
            Shutdown();
        }
Exemple #20
0
        void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
        {
            MessageBoxResult result = MessageBox.Show("Exception, sorry:" + e.Exception.Message, "Exception", MessageBoxButton.OK);

            if (result == MessageBoxResult.OK)
            {
                File.AppendAllText("exceptions.errorlog", string.Format("{0}-{1}-{2}-{3}-{4}-{5}{6}", e.Exception.Message, e.Dispatcher.ToString(), e.ToString(), e.Exception.Source.ToString(), e.Exception.TargetSite.Name, e.Exception.TargetSite.ToString(), Environment.NewLine));
                e.Handled = true;
                Environment.Exit(1);
            }
        }
Exemple #21
0
 /// <summary>
 /// 程序中出现未捕获的异常
 /// </summary>
 private void ApplicationUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
 {
     _loggor.Error("ApplicationUnhandledException", e.Exception ?? new Exception(e.ToString()));
     MessageBox.Show(MessageResource.AppErrorTip);
 }
Exemple #22
0
 private void Application_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
 {
     Log4NetLogger.GetInstance.Error(e.ToString());
 }