Пример #1
0
        private static void  OnDispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
        {
            string errorMessage = $"An unhandled exception occurred: {e.Exception.Message}";

            MessageBox.Show(errorMessage, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            e.Handled = true;
        }
Пример #2
0
        void OnDispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
        {
            //e.Handled = true; // Not handled

            _logger.Fatal(e.Exception, e.Exception.ToString());
            MessageBox.Show("Sorry for the inconvenience. The programm went into an error. See Log for more details", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
        }
Пример #3
0
        public void OnDispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
        {
            string errorMessage = string.Format("An error occurred: {0} {1}", e.Exception.InnerException, e.Exception.Message);

            MessageBox.Show(errorMessage, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            e.Handled = true;
        }
Пример #4
0
        void Application_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
        {
            MessageBox.Show(e.Exception.Message, CoC.Bot.Properties.Resources.AppName, MessageBoxButton.OK, MessageBoxImage.Exclamation);

            // Prevent default unhandled exception processing
            e.Handled = true;
        }
Пример #5
0
 private void Application_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
 {
     if (this.DoHandle)
     {
         //Handling the exception within the UnhandledException handler.
         if (e.Exception != null)
         {
             GuiUtils.ShowError(Utils.GetExceptionErrorString(e.Exception, "[APPLICATION WILL CLOSE] "), GuiUtils.MainWindowInstance);
         }
         else
         {
             MessageBox.Show("Application is going to close! ", "Exception caught.");
         }
         e.Handled = false;
     }
     else
     {
         //If you do not set e.Handled to true, the application will close due to crash.
         if (e.Exception != null)
         {
             GuiUtils.ShowError(Utils.GetExceptionErrorString(e.Exception, "[APPLICATION WILL CLOSE] "), GuiUtils.MainWindowInstance);
         }
         else
         {
             MessageBox.Show("Application is going to close! ", "Uncaught Exception");
         }
         e.Handled = false;
     }
 }
Пример #6
0
 /// <summary>
 /// The App_DispatcherUnhandledException.
 /// </summary>
 /// <param name="sender">The sender<see cref="object"/>.</param>
 /// <param name="e">The e<see cref="System.Windows.Threading.DispatcherUnhandledExceptionEventArgs"/>.</param>
 private void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
 {
     _log.Info("进行全局异常处理!");
     MessageBox.Show("出现错误,需要重新启动软件!", "警告!");
     //处理完后,我们需要将Handler=true表示已此异常已处理过
     e.Handled = true;
 }
Пример #7
0
 public static void DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
 {
     //handle ui thread exceptions
     Report(e.Exception);
     //prevent crash
     e.Handled = true;
 }
Пример #8
0
 private void App_DispatcherUnhandledException(object sender,
     DispatcherUnhandledExceptionEventArgs e)
 {
     MessageBox.Show("An unhandled " + e.Exception.GetType().ToString() + 
         " exception was caught and ignored.");
     e.Handled = true;
 }
Пример #9
0
 private void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
 {
     System.Windows.MessageBox.Show("Uncaught exception in Auremo.\n" +
                                    "Please take a screenshot of this message and send it to the developer.\n\n" +
                                    e.Exception.ToString(),
                                    "Auremo has crashed!");
 }
Пример #10
0
        void AppDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
        {
            //do whatever you need to do with the exception
            MessageBox.Show(e.Exception.Message);

            e.Handled = true;
        }
Пример #11
0
		private void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
		{
#if (!DEBUG)
			var date = DateTime.Now;
			var fileName = "Crash Reports\\"
			               + string.Format("Crash report {0}{1}{2}-{3}{4}", date.Day, date.Month, date.Year, date.Hour, date.Minute);

			if(!Directory.Exists("Crash Reports"))
				Directory.CreateDirectory("Crash Reports");

			using(var sr = new StreamWriter(fileName + ".txt", true))
			{
				sr.WriteLine("########## " + DateTime.Now + " ##########");
				sr.WriteLine(e.Exception);
				sr.WriteLine(Core.MainWindow.Options.OptionsTrackerLogging.TextBoxLog.Text);
			}

			MessageBox.Show(
			                "A crash report file was created at:\n\"" + Environment.CurrentDirectory + "\\" + fileName
			                + ".txt\"\n\nPlease \na) create an issue on github (https://github.com/Epix37/Hearthstone-Deck-Tracker) \nor \nb) send me an email ([email protected]).\n\nPlease include the generated crash report(s) and a short explanation of what you were doing before the crash.",
			                "Oops! Something went wrong.", MessageBoxButton.OK, MessageBoxImage.Error);
			e.Handled = true;
			Shutdown();
#endif
		}
Пример #12
0
        private void Application_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
        {
            // If we're running around with plugins and reflection, the last Exception is often a TargetInvocationException that isn't helpful at all,
            // but the next InnerException is
            var ex = e.Exception;
            if (ex != null && ex.GetType() == typeof(TargetInvocationException) && ex.InnerException != null)
                ex = ex.InnerException;

            // Now we'll use two possible ways to show this Exception. First - and coolest by far - is a Error entry in the logviewer.
            // But this requires the logviewer to work, which could get difficult while startup
            if (AwesomeViewerStolenFromTheInternet.ReadyToShowErrorMessages)
            {
                AwesomeViewerStolenFromTheInternet.LogException(ex);
                e.Handled = true;
            }

            else
            {
                // Then we'll just add all the error messages to one nice report
                var errMsg = "";
                var inner = ex;
                while (inner != null)
                {
                    errMsg += ex.Message + Environment.NewLine;
                    inner = inner.InnerException;
                }

                // And post it in a MessageBox - "Ok" says "go on", "Cancel" says exit the program. The latter is useful when you got
                // something that spams Exceptions.
                e.Handled = MessageBox.Show(ex.Message, "Error", MessageBoxButton.OKCancel, MessageBoxImage.Error) == MessageBoxResult.OK;
            }
        }
Пример #13
0
        private void App_OnUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
        {
            const string applicationTitle = "Music Manager";
            const string logMessage = "An unhandled exception occurred";

            string userMessage = string.Format("Oops!!! '{0}' ran into a problem. "
                                    + "The error details have been saved to the local log file.",
                                    applicationTitle);
            string userMsgIfErrorHandlingFails = string.Format("Oops!!! '{0}' ran into a problem. "
                                    + "Poosibly an error occured while bootstrapping the application.",
                                    applicationTitle);
            try
            {
                var errorHandler = _container.Resolve<IErrorHandler>();
                errorHandler.HandleError(e.Exception, logMessage, userMessage);
            }
            catch (Exception exception)
            {
                var logger = _container.Resolve<ILogger>();
                logger.LogError(logMessage, exception);

                var promptService = new PromptService(applicationTitle);
                promptService.ShowError(userMsgIfErrorHandlingFails);
            }

            e.Handled = true;
        }
Пример #14
0
        /// <summary>
        /// Catch all Exceptions in the Application
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnDispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
        {
            // Hide Load Spinner
            Messenger.Default.Send(new Model.Messages.UpdateStatusBar()
            {
                Status = false
            });

            string message;

            // Trying to get inner exceptions
            if (e.Exception.InnerException != null)
            {
                if (e.Exception.InnerException.InnerException != null)
                {
                    message = e.Exception.InnerException.InnerException.Message;
                }
                else
                {
                    message = e.Exception.InnerException.Message;
                }
            }
            else
            {
                message = e.Exception.Message;
            }

            MessageBox.Show(message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            e.Handled = true;
        }
Пример #15
0
        private void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
        {
            _isSaved = true;
            try
            {
                MainTokenSource.Cancel();
            }
            catch
            {
            }
            finally
            {
                MainTokenSource.Dispose();
            }

            #if !DEBUG
            if (e.Exception == null)
            {
                Application.Current.Shutdown();
                return;
            }
            //Log.Logger.Default.AddLogItem(new Log.LogItem(e.Exception));
            MessageBox.Show("发生内部错误\n\n" + e.Exception.ToString(), App.NAME);
            e.Handled = true;
            Application.Current.Shutdown();
            #endif
        }
Пример #16
0
        void OnDispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
        {
            string errorMessage = string.Format("There is a problem! Please, try to restart the application!");

            MessageBox.Show(errorMessage, "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
            e.Handled = true;
        }
Пример #17
0
 private static void OnUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
 {
     //ReportUnhandledException(e.Exception);
     //throw e.Exception;
     AppServices.Dialog.ShowWarning(e.Exception.Message);
     e.Handled = true;
 }
Пример #18
0
 private void Application_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
 {
     Exception exception = e.Exception;
     if (exception is XamlParseException)
         exception = exception.GetBaseException();
     Trace.TraceError(((object)exception).ToString());
 }
Пример #19
0
 private void Application_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
 {
     MessageBox.Show(e.Exception.Message + "\r\n" + e.Exception.StackTrace, "Application Error",
         MessageBoxButton.OK, MessageBoxImage.Error);
     e.Handled = false;
     App.Current.Shutdown();
 }
Пример #20
0
 // Global exception handling
 // (event handler registered in App.xaml)
 void Application_DispatcherUnhandledException( object sender, DispatcherUnhandledExceptionEventArgs e )
 {
     if ( e.Exception is DistributorIntegrityNotLicensedException )
     {
         ShowErrorMessageBox( "There's an integrity issue with your distributor. Please contact your Distributor Administrator." );
         e.Handled = true;
     }
     else if ( e.Exception is DistributorNotLicensedException )
     {
         ShowErrorMessageBox( "There's a problem with your distributor. Please check your Licensing Configuration." );
         e.Handled = true;
     }
     else if ( e.Exception is NotLicensedException )
     {
         ShowErrorMessageBox( "You don't have a license for this feature. Please check your Licensing Status." );
         e.Handled = true;
     }
     else
     {
         //All other exceptions
         string exceptionMessage = e.Exception != null ? e.Exception.ToString() : e.ToString();
         ShowErrorMessageBox( "An error occurred: " + exceptionMessage );
         e.Handled = false;
     }
 }
 public void ShowError(object sender, DispatcherUnhandledExceptionEventArgs args)
 {
     Visibility = Visibility.Visible;
     Exception exception = args.Exception;
     ErrorMessage.Content = "Error: " + exception.Message;
     args.Handled = true;
 }
Пример #22
0
 void Current_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
 {
     //MessageBox.Show(e.Exception.Message);
     e.Handled = true;
     //UIHelper.WriteLog(e.Exception.Message);
     Log.CreateLog(e.Exception);
 }
Пример #23
0
        private void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
        {
            #if(DEBUG)
            //Just so resharper codecleanup does not remove using system and system.io when in debug
            if(File.Exists("HearthstoneDeckTracker.exe"))
                Console.WriteLine("Ignore this");
            #endif
            #if (!DEBUG)
            var date = DateTime.Now;
            var fileName = "Crash Reports/" + string.Format("Crash report {0}{1}{2}-{3}{4}", date.Day, date.Month, date.Year, date.Hour, date.Minute);

            if (!Directory.Exists("Crash Reports"))
                Directory.CreateDirectory("Crash Reports");

            using (var sr = new StreamWriter(fileName + ".txt", true))
            {
                sr.WriteLine("########## " + DateTime.Now + " ##########");
                sr.WriteLine(e.Exception);
            }

            MessageBox.Show("Something went wrong.\nA crash report file was created at:\n\"" + Environment.CurrentDirectory + "\\" + fileName + "\"\nPlease create an issue in the github, message me on reddit (/u/tnx) or send this file to [email protected], with a short explanation of what you were doing before the crash.", "Oops!", MessageBoxButton.OK, MessageBoxImage.Error);
            e.Handled = true;
            Shutdown();
            #endif
        }
Пример #24
0
 /// <summary>
 /// A callback for non-caught exceptions. 
 /// 
 /// Only reports to the crash logger in release.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 public void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
 {
     _logger.Error(e.Exception, "Uncatched error!");
     #if !DEBUG
     _raygun.Send(e.Exception, null, GetLogs());
     #endif
 }
Пример #25
0
 private void HandleUnhandledUIException(object sender,DispatcherUnhandledExceptionEventArgs e)
 {
     e.Handled = true;
     Exception ex = e.Exception as Exception;
     log.Error(ex.Message, ex);
     ShowToUserMessage(ex);
 }
Пример #26
0
 private void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
 {
     if (!e.Handled)
     {
         ServiceProvider.GetService <IWindowService>().ShowError(e.Exception);
     }
 }
Пример #27
0
        private void ShowUnhandeledException(DispatcherUnhandledExceptionEventArgs e)
        {
            e.Handled = true;

            string errorMessage =
                string.Format(
                    "An application error occurred.\nPlease check whether your data is correct and repeat the action. If this error occurs again there seems to be a more serious malfunction in the application, and you better close it.\n\nError:{0}\n\nDo you want to continue?\n(if you click Yes you will continue with your work, if you click No the application will close)",

                    e.Exception.Message + (e.Exception.InnerException != null
                        ? "\n" +
                          e.Exception.InnerException.Message
                        : null));

            Trace.TraceError(errorMessage);
            Trace.TraceError("Stack Trace " + e.Exception.StackTrace);
            Trace.TraceError("Source " + e.Exception.Source);
            Trace.TraceError("Inner Exception3 " + e.Exception.InnerException);

            //if (
            //    MessageBox.Show(errorMessage, "Application Error", MessageBoxButton.YesNoCancel, MessageBoxImage.Error, MessageBoxResult.No) ==
            //    MessageBoxResult.Yes)
            {
                {

                    Application.Current.Shutdown();
                }
            }
        }
 private void Application_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
 {
     if (ignore.IsChecked != null && ignore.IsChecked.Value)
     {
         e.Handled = true;
     }
 }
Пример #29
0
		protected override void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
		{
			logger.Error(e.Exception);
			e.Handled = true;

			base.OnDispatcherUnhandledException(sender, e);
		}
Пример #30
0
        protected override void OnUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
        {
            var message = e.Exception?.ToString();

            System.IO.File.WriteAllText(Environment.CurrentDirectory + "\\SharpGraphEditor_unhandled_exception_log.txt", message);
            e.Handled = false;
        }
Пример #31
0
        private void OnUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
        {
            e.Handled = true;

            ErrorControl.Visibility = Visibility.Visible;
            ErrorControl.Message = e.Exception.Message;
        }
Пример #32
0
 public void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
 {
     string errorMessage = string.Format("An unhandled exception occurred: {0}", e.Exception.Message);
     MessageBox.Show(errorMessage, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
     e.Handled = true;
     ((MainWindow)MainWindow).diagnostic.AddException(e.Exception);
 }
Пример #33
0
 private void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs eventArgs)
 {
     Log.Fatal("Unhandled Exception.", eventArgs.Exception);
     eventArgs.Handled = true;
     MessageBox.Show("An unexpected error has occured. Please submit the log file.", "Oops!");
     Shutdown();
 }
Пример #34
0
        private void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
        {
            LogService.RecordException(sender, e.Exception);

            e.Handled = true;
            Application.Current.Shutdown();
        }
        private void ApplicationDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
        {
            e.Handled = true;

            if (UnityContainer != null)
            {
                var computerName = Environment.MachineName;
                var currentUser = UnityContainer.Resolve<ICurrentUser>();
                var environment = ConfigurationManager.AppSettings["Environment"];
                var applicationName = ConfigurationManager.AppSettings["ApplicationName"];

                var randomNumber = (new Random()).Next(0, 1000).ToString("D4");
                var errorId = string.Format("{0}-{1}-{2}", currentUser.Username, currentUser.LabCode, randomNumber);

                using (LogContext.PushProperty("ErrorId", errorId))
                using (LogContext.PushProperty("Username", currentUser.Username))
                using (LogContext.PushProperty("LabCode", currentUser.LabCode))
                using (LogContext.PushProperty("ComputerName", computerName))
                using (LogContext.PushProperty("Environment", environment))
                using (LogContext.PushProperty("ApplicationName", applicationName))
                {
                    // Not very descriptive message
                    //Logger.Fatal(e.Exception, "A fatal error occured.");

                    // More humanly readable message
                    Logger.Fatal(e.Exception, "A fatal error occured in the User interface of {ApplicationName} in {Environment} on the machine {ComputerName} where user {Username} was logged on.",
                      applicationName, environment, computerName, currentUser.Username);

                    MessageBox.Show(String.Format("A fatal error occured and the application has to shutdown.Please contanct help desk using the following Error Id: {0}", errorId));
                    Current.Shutdown();
                }
            }
        }
Пример #36
0
        private void appDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
        {
            new ExceptionLogger().LogExceptionToFile(e.Exception, AppMessenger.LogFile);
            e.Handled = true;

            addException(e.Exception);
        }
Пример #37
0
        void Application_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
        {
            var comException = e.Exception as System.Runtime.InteropServices.COMException;

            if (comException != null && comException.ErrorCode == -2147221040)
                e.Handled = true;
        }
Пример #38
0
 private void My_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
 {
     if (e != null)
     {
         e.Handled = this.ShowException(e.Exception);
     }
 }
Пример #39
0
        private void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
        {
            MessageBox.Show(e.Exception.Message, Comdat.DOZP.Scan.Properties.Resources.ApplicationName);
            Logger.Log(e.Exception.Message);

            e.Handled = true;
        }
Пример #40
0
        void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
        {
            //可以记录日志并转向错误bug窗口友好提示用户
            e.Handled = true;
            string estring = e.Exception.Message + "\r\n" + e.Exception.StackTrace;

#if DEBUG
            Console.WriteLine("Wrong:" + estring);
#endif
            if (e.Exception.Source.StartsWith("Python"))
            {
                using (Py.GIL())
                {
                    string stack = e.Exception.StackTrace;
                    int    idx   = stack.IndexOf(']');
                    stack = stack.Substring(0, idx);
                    string pattern = "(')(?:(?!\\1).)*?\\1";
                    PyPrint(e.Exception.Message);
                    PyPrint("Traceback");
                    foreach (Match match in Regex.Matches(stack, pattern))
                    {
                        var tims = match.Value.Trim('\'');
                        tims = tims.Replace("\\n", "\n");
                        PyPrint(tims);
                    }
                }
            }
        }
 void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
 {
     //处理完后,我们需要将Handler=true表示已此异常已处理过
     myEventLog.LogError("捕获到全局异常:" + e.Exception.Message, e.Exception);
     MessageBox.Show("程序出现异常,请联系支持");
     e.Handled = true;
 }
Пример #42
0
 private void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
 {
     Logger.Log.Error("Unhandled exception", e.Exception);
     MessagingService.ShowErrorMessage(Common.Resources.Strings.Resources.UnhandledException,
         e.Exception.ToString(), false);
     e.Handled = true;
 }
Пример #43
0
        //private static void HandleSolutionLoadSourceControl(Solution solution)
        //{
        //    string RepositoryRootFolder = string.Empty;
        //    SourceControlBase.eSourceControlType type = SourceControlIntegration.CheckForSolutionSourceControlType(solution.Folder, ref RepositoryRootFolder);
        //    if (type == SourceControlBase.eSourceControlType.GIT)
        //    {
        //        solution.SourceControl = new GITSourceControl();
        //    }
        //    else if (type == SourceControlBase.eSourceControlType.SVN)
        //    {
        //        solution.SourceControl = new SVNSourceControl();
        //    }

        //    if (solution.SourceControl != null)
        //    {
        //        if (string.IsNullOrEmpty(WorkSpace.Instance.UserProfile.SolutionSourceControlUser) || string.IsNullOrEmpty(WorkSpace.Instance.UserProfile.SolutionSourceControlPass))
        //        {
        //            if (WorkSpace.Instance.UserProfile.SourceControlUser != null && WorkSpace.Instance.UserProfile.SourceControlPass != null)
        //            {
        //                solution.SourceControl.SourceControlUser = WorkSpace.Instance.UserProfile.SourceControlUser;
        //                solution.SourceControl.SourceControlPass = WorkSpace.Instance.UserProfile.SourceControlPass;
        //                solution.SourceControl.SolutionSourceControlAuthorEmail = WorkSpace.Instance.UserProfile.SolutionSourceControlAuthorEmail;
        //                solution.SourceControl.SolutionSourceControlAuthorName = WorkSpace.Instance.UserProfile.SolutionSourceControlAuthorName;
        //            }
        //        }
        //        else
        //        {
        //            solution.SourceControl.SourceControlUser = WorkSpace.Instance.UserProfile.SolutionSourceControlUser;
        //            solution.SourceControl.SourceControlPass = WorkSpace.Instance.UserProfile.SolutionSourceControlPass;
        //            solution.SourceControl.SolutionSourceControlAuthorEmail = WorkSpace.Instance.UserProfile.SolutionSourceControlAuthorEmail;
        //            solution.SourceControl.SolutionSourceControlAuthorName = WorkSpace.Instance.UserProfile.SolutionSourceControlAuthorName;
        //        }

        //        string error = string.Empty;
        //        solution.SourceControl.SolutionFolder = solution.Folder;
        //        solution.SourceControl.RepositoryRootFolder = RepositoryRootFolder;
        //        solution.SourceControl.SourceControlURL = solution.SourceControl.GetRepositoryURL(ref error);
        //        solution.SourceControl.SourceControlLocalFolder = WorkSpace.Instance.UserProfile.SourceControlLocalFolder;
        //        solution.SourceControl.SourceControlProxyAddress = WorkSpace.Instance.UserProfile.SolutionSourceControlProxyAddress;
        //        solution.SourceControl.SourceControlProxyPort = WorkSpace.Instance.UserProfile.SolutionSourceControlProxyPort;
        //        solution.SourceControl.SourceControlTimeout = WorkSpace.Instance.UserProfile.SolutionSourceControlTimeout;

        //        WorkSpace.Instance.SourceControl = solution.SourceControl;
        //        RepositoryItemBase.SetSourceControl(solution.SourceControl);
        //        RepositoryFolderBase.SetSourceControl(solution.SourceControl);
        //    }
        //}

        private void Application_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
        {
            Exception ex = e.Exception;

            WorkSpace.Instance.Telemetry.AddException(ex);
            //Exceptions to avoid because it source is in some .NET issue
            if (ex.Message == "Value cannot be null.\r\nParameter name: element" && ex.Source == "PresentationCore")//Seems like WPF Bug
            {
                e.Handled = true;
                return;
            }

            //log it
            Reporter.ToLog(eLogLevel.ERROR, ex.ToString(), ex);

            //add to dictionary to make sure same exception won't show more than 3 times
            if (mExceptionsDic.ContainsKey(ex.Message))
            {
                mExceptionsDic[ex.Message]++;
            }
            else
            {
                mExceptionsDic.Add(ex.Message, 1);
            }

            if (mExceptionsDic[ex.Message] <= 3)
            {
                Ginger.GeneralLib.ExceptionDetailsPage.ShowError(ex);
            }

            // Clear the err so it will not crash
            e.Handled = true;
        }
Пример #44
0
        private void Application_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
        {
            string fileName = "app_" + DateTime.Now.ToString("yyyyMMdd") + ".log";
            string path     = System.IO.Path.Combine(AppContext.BaseDirectory, fileName);

            File.AppendAllText(path, $"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")} [{e.Exception.Message}] {"Application处理异常"} " + Environment.NewLine);
            e.Handled = true;
        }
Пример #45
0
 private void Current_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs args)
 {
     if (args != null)
     {
         StaticLogger.LogException(args.Exception);
         args.Handled = true;
     }
 }
Пример #46
0
        public void Application_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
        {
            MessageBox.Show(e.Exception.Message, "Exception sample", MessageBoxButton.OK, MessageBoxImage.Warning);

            e.Handled = true;

            var window = Application.Current.Windows.OfType <MainWindow>().SingleOrDefault(x => x.IsActive);
        }
Пример #47
0
 private void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
 {
     e.Handled = true;
     if (e.Exception != null)
     {
         ShowAndLogError(e.Exception);
     }
 }
Пример #48
0
 static void Current_DispatcherUnhandledException(object sender, Threading.DispatcherUnhandledExceptionEventArgs e)
 {
     if (!e.Handled && e.Exception is MessageBoxException mbe)
     {
         e.Handled = true;
         mbe.Show();
     }
 }
Пример #49
0
        private void Application_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
        {
            try
            {
                var exception = null as Exception;
                if (e != null && e.Exception != null)
                {
                    //исключить сообщения о разрыве связи
                    if (e.Exception is TimeoutException || e.Exception is DeploymentDownloadException)
                    {
                        e.Handled = true;
                        return;
                    }
                    else if (e.Exception is InvalidOperationException &&
                             e.Exception.Message == "Dispatcher processing has been suspended, but messages are still being processed.")
                    {
                        e.Handled = true;
                        return;
                    }
                    else if (e.Exception is InvalidOperationException &&
                             e.Exception.Message.EndsWith("VisualLineElementGenerator, but it is not collapsed."))
                    {
                        e.Handled = true;
                        return;
                    }
                    else if (e.Exception != null && e.Exception.InnerException != null)
                    {
                        exception = e.Exception.InnerException;
                    }
                    else if (e.Exception != null)
                    {
                        exception = e.Exception;
                    }

                    if (exception != null)
                    {
                        AddLog(exception);
                    }
                }

                if (!App.ежимТестирования)
                {
                    e.Handled = true;
                    return;
                }
                else if (exception != null)
                {
                    MessageBox.Show(exception.Message, "Ошибка в приложении", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                e.Handled = true;
            }
        }
Пример #50
0
        void OnDispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
        {
            string errorMessage = string.Format("An unhandled exception occurred: {0}", e.Exception.Message);

            MessageBox.Show(errorMessage, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            // OR whatever you want like logging etc. MessageBox it's just example
            // for quick debugging etc.
            e.Handled = true;
        }
Пример #51
0
        /// <summary>
        /// 全局异常处理逻辑
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
        {
            int rec = PFM.DawnXZ.Library.Transit.ErrorTsit.Insert(e.Exception);

            PFM.DawnXZ.Library.Transit.LoggerTsit.Write(e.Exception);
            MessageBox.Show("发生异常,请确认操作是否正确!详情请于《错误消息》浏览。", "错误", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
            //处理完后,我们需要将Handler=true表示已此异常已处理过
            e.Handled = true;
        }
Пример #52
0
 private void Dispatcher_UnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
 {
     _raven.Capture(new SentryEvent(e.Exception));
     Log.Divider();
     Log.Error("Fatal unhandled exception");
     Log.Exception(e.Exception);
     Log.WriteToFile();
     AppLib.WPF.Dialogs.Dialogs.ShowErrorDialog(e.Exception);
 }
Пример #53
0
 void Current_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
 {
     if (handled)
     {
         return;
     }
     handled = true;
     HandleException(e.Exception);
 }
        private void Dispatcher_UnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
        {
            ILoggerService logService = LifetimeService.Instance.Container.Resolve <ILoggerService>();

            logService.WriteToLogLevel("Unhandled Exception Occured in App's main window :", LogLevelEnum.Fatal, e.Exception);
            MessageBox.Show("Main Window:" + e.Exception.ToString());
            e.Handled = true;// if you false this and comment following line, then, exception goes to XAML Application Exception
            Environment.Exit(0);
        }
Пример #55
0
        private static void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
        {
            CreateMiniDump();

            //Thread.Sleep(2000);
            //Process proc = new Process();
            //proc.StartInfo.FileName = @"WpfAppdump.exe";
            //proc.StartInfo.WorkingDirectory = Path.GetDirectoryName(@"WpfAppdump.exe");
            //proc.Start();
        }
Пример #56
0
        void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
        {
            Trace.TraceError(e.Exception.GetMessages());

#if DEBUG
            MessageBox.Show(e.Exception.Message + "\r\n -> " + e.Exception.StackTrace, "Error! (Debug mode)", MessageBoxButton.OK, MessageBoxImage.Error);
#else
            MessageBox.Show(e.Exception.Message, "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
#endif
            e.Handled = true;
        }
Пример #57
0
        void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
        {
            string errorSaveFiler = Directory.GetCurrentDirectory() + "\\errorlog.txt";//用户账号保存文件

            try
            {
                File.AppendAllText(errorSaveFiler, "\r\n" + DateTime.Now.ToString() + "      " + e.Exception.ToString());
            }
            catch
            {
            }
        }
Пример #58
0
 /// <summary>
 /// Handles the DispatcherUnhandledException event of the Application control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="System.Windows.Threading.DispatcherUnhandledExceptionEventArgs"/> instance containing the event data.</param>
 private void Application_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
 {
     try
     {
         AppCore.Log.Error("Unhandled Exception", e.Exception);
         ErrorForm.Show(e);
     }
     catch (Exception ex)
     {
         Trace.TraceError(ex.ToString());
     }
 }
Пример #59
0
 void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
 {
     try
     {
         e.Handled = true; //把 Handled 属性设为true,表示此异常已处理,程序可以继续运行,不会强制退出
         Log.Error("UI线程异常:" + e.Exception.Message);
     }
     catch (Exception ex)
     {
         //此时程序出现严重异常,将强制结束退出
         Log.Error("UI线程发生致命错误!" + ex.Message);
     }
 }
Пример #60
0
 void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
 {
     try
     {
         e.Handled = true; //把 Handled 属性设为true,表示此异常已处理,程序可以继续运行,不会强制退出
         MessageBox.Show("UI线程异常:" + e.Exception.Message + "\r\n" + e.Exception?.InnerException?.Message + "\r\n" + e.Exception.StackTrace);
     }
     catch (Exception)
     {
         //此时程序出现严重异常,将强制结束退出
         MessageBox.Show("UI线程发生致命错误!");
     }
 }