Пример #1
0
        static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            string str = GetExceptionMsg(e.ExceptionObject as Exception, e.ToString());

            MessageBox.Show(str, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            FileOperation.WriteLog(DateTime.Now.ToString() + "\r\n" + str);
            //查看若发现异常是在设置软体上出现的,此时是需要我们做数据保存
            if (null != frm.MyParamSet)
            {
                SysParam.SaveAllInfor();
            }
        }
        private void CatchUnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            Console.WriteLine("The service threw an unhandled exception: {0}", e.ToString());

            if (!e.IsTerminating)
            {
                return;
            }

            _exitCode = ExitCode.UnhandledServiceException;
            _exit.Set();
        }
Пример #3
0
        private static void UnhandledExceptionTrapper(object sender, UnhandledExceptionEventArgs e)
        {
            Log.Fatal(nameof(UnhandledExceptionTrapper));
            Log.Fatal(e.ToString());

            Log.Fatal((Exception)e.ExceptionObject);

            if (_pushover != null)
            {
                _ = _pushover.SendMessageAsync($"Exception occured @ {DateTime.Now:HH:mm}", $"{nameof(AltradyNotifier)} crashed, an unhandled exception occured");
            }
        }
Пример #4
0
 public static void UExecptionHandler(UnhandledExceptionEventArgs args)
 {
     if (args.IsTerminating)
     {
         Console.WriteLine(args.ToString());
     }
     else
     {
         new SafeCallDialog("Das programm hat sich mit folgender Fehlermeldung beendet:\n" + args.ExceptionObject, "Ok", 0, null, 0).Run();
     }
     Application.Quit();
 }
Пример #5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 public static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
 {
     try
     {
         string msg = "系统发生未处理的异常!";
         msg += e.ToString();
         msg += e.ExceptionObject.ToString();
         throw new Exception(msg);
     }
     catch
     {
     }
 }
Пример #6
0
        private static void CurrentDomainUnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            Exception ex = e.ExceptionObject as Exception;

            if (ex != null)
            {
                MessageBox.Show(ex.Message, "Uncaught Thread Exception", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else
            {
                MessageBox.Show(e.ToString(), "Uncaught Thread Exception", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Пример #7
0
        static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            string str1 = null;
            string str  = null;

            var ex = e.ExceptionObject as Exception;

            do
            {
                str1 = GetExceptionMsg(ex, e.ToString());
                str  = GetExceptionMsgInfo(ex, e.ToString());
                writeLog(str1);

                if (YCF.Common.CommonHelper.IsDebug)
                {
                    MessageBox.Show(str1);
                }

                ex = ex.InnerException;
            } while (ex != null);

            MessageBox.Show(str, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
Пример #8
0
        private static void LogException(object sender, UnhandledExceptionEventArgs e)
        {
            string errordir = Path.Combine(Application.StartupPath, "errorlog");
            string errorlog = Path.Combine(errordir, DateTime.Now.ToString("yyyyMMdd_HHmmss_fff") + ".txt");

            if (!Directory.Exists(errordir))
            {
                Directory.CreateDirectory(errordir);
            }
            File.WriteAllText(errorlog, e.ToString());
            AppDomain.CurrentDomain.UnhandledException -= LogException;
            MessageBox.Show("Error details recorded in " + errorlog, "Unexpected error");
            Environment.Exit(1);
        }
Пример #9
0
        protected async override void OnUnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            if (e.Exception != null)
            {
                //
            }
#if DEBUG
            e.Handled = true;
            var md = new MessageDialog(e.ToString());
            await md.ShowAsync();
#else
            base.OnUnhandledException(sender, e);
#endif
        }
Пример #10
0
        private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            logIt(e.ToString());
            Exception ex = default(Exception);

            ex = (Exception)e.ExceptionObject;
            logIt(ex.StackTrace);
            if (ewait != null)
            {
                ewait.Set();
                //ewait.Close();
            }
            //
        }
Пример #11
0
 private void Error_UnhandledException(object sender, UnhandledExceptionEventArgs e)
 {
     MessageBox.Show(e.IsTerminating.ToString());
     if (e.ExceptionObject is Exception ex)
     {
         LogError($"Unhandling error: {ex}");
         ShowErrorDialog(e.ExceptionObject as Exception);
     }
     else
     {
         LogError($"Unhandling error: {e}");
         MessageBox.Show("Unhandeled error:\n" + e.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Пример #12
0
 static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
 {
     if (!Globals.IsSilentInstall)
     {
         MessageBox.Show(((Exception)e.ExceptionObject).ToString());
     }
     else
     {
         Globals.SilentInstallCommunicationPipeStream.WriteString("[Error]" + e.ToString());
         Globals.SilentInstallCommunicationPipe.WaitForPipeDrain();
         Globals.SilentInstallCommunicationPipe.Close();
         System.Environment.Exit(0);
     }
 }
Пример #13
0
        public static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            string str = GetExceptionMsg(e.ExceptionObject as Exception, e.ToString());
            //log4net.ILog log = log4net.LogManager.GetLogger((e.ExceptionObject as Exception).GetType());
            //log.Debug("CurrentDomain_UnhandledException Enter initMenus()");
            //log.Error(str.ToString());
            LogInfo logInfo = new LogInfo();

            logInfo.IsEnable   = true;
            logInfo.LogContent = str;
            logInfo.LogName    = "非UI线程异常";
            logInfo.LogTime    = DateTime.Now;
            logInfo.LogType    = ((LogType)3).ToString();
            //db.Add<LogInfo>(logInfo);
        }
Пример #14
0
        private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            logIt(e.ToString());
            Exception ex = default(Exception);

            ex = (Exception)e.ExceptionObject;
            logIt(ex.StackTrace);
            if (ewait != null)
            {
                ewait.Set();
                //ewait.Close();
            }
            Thread.Sleep(5000);
            Util.runExeOnly(System.Reflection.Assembly.GetEntryAssembly().Location, "-start-service");
            Environment.Exit(1000);
        }
Пример #15
0
        private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            SmartX.SmartFile m_smartFile = m_smartFile = new SmartX.SmartFile();

            m_smartFile.FilePathName = "\\Flash Disk\\ErrorLog.txt";
            if (m_smartFile.Open() == true)
            {
                m_smartFile.WriteString(e.ToString());
                m_smartFile.Close();
            }
            else
            {
                ;
            }
            // 처리되지 않는 모든 예외처리 코드 작성
        }
Пример #16
0
        static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            LogHelper.LogError(sender.GetType().Name, e.ToString());
            LogHelper.LogError(sender.GetType().Name, e.ExceptionObject.ToString());

            while (true)
            {     //循环处理,否则应用程序将会退出
                if (glExitApp)
                { //标志应用程序可以退出,否则程序退出后,进程仍然在运行
                    LogHelper.LogError(sender.GetType().Name, "ExitApp :" + e.ExceptionObject.ToString());
                    return;
                }
                System.Threading.Thread.Sleep(2 * 1000);
            }
            ;
        }
Пример #17
0
        //Puts up an error message box, writes the exception to the log, and closes the program.
        private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            MessageBox.Show($"An exception occured. If you report this, make sure they can see this next part:\n {e.ExceptionObject?.GetType()}", "Fatal Error!",
                            MessageBoxButtons.OK, MessageBoxIcon.Error);

            //Writes to log file.
            using (StreamWriter sw = File.AppendText("Log.txt"))
            {
                sw.WriteLine("\n=====EXCEPTION OCCURED!=====\n");
                sw.WriteLine(e.ToString());
                sw.WriteLine(e.ExceptionObject?.GetType());
            }



            Application.Exit();
        }
Пример #18
0
        private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            var exception = e.ExceptionObject as Exception;

            if (exception != null)
            {
                while (exception.InnerException != null)
                {
                    exception = exception.InnerException;
                }
                Logger.FATAL(exception.ToString());
            }
            else
            {
                Logger.FATAL(e.ToString());
            }
        }
Пример #19
0
        static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            Exception ex;

            if (e.ExceptionObject is Exception)
            {
                ex = (Exception)e.ExceptionObject;
            }
            else
            {
                ex = new Exception(e.ToString());
            }

            General.ErrorMessage = ex.GetType().Name + ": " + ex.Message + "\r\n" + ex.StackTrace;
            General.WriteLogLine(General.ErrorMessage);
            mainwindow.ShowTaggedPanel("error");
        }
Пример #20
0
        private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            try
            {
                var exception = e.ExceptionObject as Exception;
                if (exception != null)
                {
                    TengDa.Common.Log.Logs.Error("非UI线程全局异常:" + e.ToString());
                }
            }
            catch (Exception ex)
            {
                TengDa.Common.Log.Logs.Error("不可恢复的非UI线程全局异常:" + ex.ToString());
                MessageBoxX.Error("应用程序发生不可恢复的异常,将要退出!");
            }

            MessageBoxX.Error("我们很抱歉,当前应用程序遇到一些问题,该操作已经终止,请进行重试,如果问题继续存在,请联系管理员.");
        }
Пример #21
0
        private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            StringBuilder errorMsg = new StringBuilder();

            errorMsg.Append("An application error occurred.\n");
            errorMsg.Append("Please check whether your data is correct and repeat the action.");
            errorMsg.Append("If this error occurs again there seems to be a more serious malfunction in the application, and you better close it.\n\n");
            errorMsg.Append("Error: ").Append(e.ToString()).Append("\n\nDo you want to continue?\n");
            errorMsg.Append("(if you click Yes you will continue with your work, if you click No the application will close)");

            if (MessageBox.Show(errorMsg.ToString(), "Application Error", MessageBoxButton.YesNoCancel, MessageBoxImage.Error) == MessageBoxResult.No)
            {
                if (MessageBox.Show("WARNING: The application will close. Any changes will not be saved!\nDo you really want to close it?", "Close the application!", MessageBoxButton.YesNoCancel, MessageBoxImage.Warning) == MessageBoxResult.Yes)
                {
                    Application.Current.Shutdown();
                }
            }
        }
Пример #22
0
        ///
        /// ------------------------------------------------------------------------------------------------
        /// Name		HandleUnhandledException
        ///
        /// <summary>	Handles the unhandled exception event and caches an event report which is read
        ///             when the app next launches.
        /// </summary>
        /// <param name="sender">		Event source.</param>
        /// <param name="e">			Exception arguments.</param>
        ///
        /// <remarks>
        /// </remarks>
        /// ------------------------------------------------------------------------------------------------
        ///
        static void HandleUnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            IOException   nsex;
            Exception     ex;
            ErrorReport   report;
            StringBuilder sb;

            //
            nsex = e.ExceptionObject as IOException;
            ex   = e.ExceptionObject as Exception;
            if (nsex != null)
            {
                report = new ErrorReport("Unhandled Native Exception", nsex);
            }
            else if (ex != null)
            {
                // Only create the crash report if the exception was not an ExitException.
                //if (ex is ExitException)
                //	return;
                //
                report = new ErrorReport("Unhandled Managed Exception", ex);
            }
            else
            {
                report = new ErrorReport("Unhandled Unrecognised Exception", e.ToString());
            }
            //
            // Make a record of the state of the data when the error occurred.
            sb = new StringBuilder();
            sb.AppendLine("Requests Data:");
            sb.AppendLine(AppData.PropertyModel.Cache.ToString());
            sb.AppendLine();
            report.AddFurtherInfo(sb.ToString());
            //
            //writingfile(report);
            //var write = await FileSystem.WriteAsync("", "error.txt");
            var fs    = new FileSystem();
            var write = fs.Write(report.Serialised, "error.txt");
        }
Пример #23
0
        /// <summary>
        /// 异常重启
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="exception"></param>
        private void unhandledException(object sender, UnhandledExceptionEventArgs exception)
        {
            object exceptionObject = exception.ExceptionObject;

            outputException(exceptionObject == null ? exception.ToString() : exceptionObject.ToString());
            try
            {
                fastCSharp.diagnostics.process.ReStart();
            }
            catch (Exception error)
            {
                outputException(error.ToString());
            }
            try
            {
                Dispose();
            }
            catch (Exception error)
            {
                outputException(error.ToString());
            }
        }
Пример #24
0
        void ApplicationUnhandledExceptionHandler(object sender, UnhandledExceptionEventArgs e)
        {
            // When a background thread crashes this is the code that will be executed. You can
            // recover from this.
            // You might for example:
            //  _CurrentActivity.RunOnUiThread(() => Toast.MakeText(_CurrentActivity, "Unhadled Exception was thrown", ToastLength.Short).Show());
            //
            // or
            //
            // _CurrentActivity.StartActivity(typeof(SomeClass));
            // _CurrentActivity.Finish();
            //
            // It is up to the developer as to what he/she wants to do here.
            //
            // If you are requiring a minimum version less than API 14, you would have to set _CurrentActivity in each time
            // a different activity is brought to the foreground.

            // Send the Exception to TestFlight.
            //			TestFlight.SendCrash(e.ToString());

            throw new System.Exception(e.ToString());
        }
Пример #25
0
        /// <summary>
        /// 集約エラーハンドラ
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            if (e.ExceptionObject is Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace);
                Console.WriteLine(ex.Message);
                this._logger.Log(LogLevel.Fatal, "ハンドリングしていない例外が発生", ex);
            }
            else
            {
                Console.WriteLine(e.ToString());
            }

            //TODO:ロギング処理など
            MessageBox.Show(
                "不明なエラーが発生しました。アプリケーションを終了します。",
                "エラー",
                MessageBoxButton.OK,
                MessageBoxImage.Error);

            Environment.Exit(1);
        }
Пример #26
0
 /// <summary>
 /// 未处理异常
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
 {
     CheerLib.LogWriter.Error("Program.CurrentDomain_UnhandledException");
     CheerLib.LogWriter.Log(e.ToString());
 }
Пример #27
0
 private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
 {
     Log.e("Unhandled Domain Exception: " + e.ToString());
 }
Пример #28
0
 private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
 {
     global::DebugPRO.LogError(e.ExceptionObject.ToString() + ":" + e.ToString());
 }
Пример #29
0
        /// <summary>
        /// 程序域中出现异常,但是没有被捕获
        /// </summary>
        private void CurrentDomainUnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            Cef.Shutdown();

            var exception = e.ExceptionObject as Exception;

            _loggor.Error("CurrentDomainUnhandledException", exception ?? new Exception(e.ToString()));
            MessageBox.Show(MessageResource.AppErrorTip);
        }
Пример #30
0
 public void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
 {
     if (e.IsTerminating)
     {
         Fatal("Application Fatal!", new Exception(string.Format("Exception Object:{0} UnhandledExceptionEventArgs:{1}", e.ExceptionObject.ToString(), e.ToString())));
     }
     else
     {
         Error("Application Error!", new Exception(string.Format("Exception Object:{0} UnhandledExceptionEventArgs:{1}", e.ExceptionObject.ToString(), e.ToString())));
     }
 }
Пример #31
0
 private async void App_UnhandledException(object sender, UnhandledExceptionEventArgs e)
 {
     MessageDialog dialog = new MessageDialog("Oops! Unhandled exception.\nDetails: " + e.ToString());
     await dialog.ShowAsync();
 }
Пример #32
0
        // Code to execute on Unhandled Exceptions
        private void Application_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            Debug.WriteLine("Exception " + e.Exception);

            if (Debugger.IsAttached)
            {
                // An unhandled exception has occurred; break into the debugger
                Debugger.Break();
            }
            else
            {
                e.Handled = true;

                MessageDialog dialog = new MessageDialog(e.ToString(), e.Message);
                dialog.Commands.Add(new UICommand("Ok"));
                dialog.ShowAsync();
            }
        }