예제 #1
0
        void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
        {
            if (log == null)
            {
                log = new Log("app_error");
            }
            ADS.BeforeClose();
            //处理完后,需要将 Handler = true 表示已处理过此异常
            e.Handled = true;
            log.LOG(e.Exception.Message + e.Exception.StackTrace);

            if (WindowCommon.ConfirmAction("是否重启,发现异常:\n" + e.Exception.Message + e.Exception.StackTrace))
            {
                //////开启新的实例
                System.Diagnostics.Process.Start(System.Windows.Forms.Application.ExecutablePath);
            }

            //////关闭当前实例
            System.Diagnostics.Process.GetCurrentProcess().Kill();
        }
예제 #2
0
        void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            //可以记录日志并转向错误bug窗口友好提示用户
            if (e.ExceptionObject is System.Exception)
            {
                if (log == null)
                {
                    log = new Log("app_error");
                }
                Exception ex = (System.Exception)e.ExceptionObject;
                log.LOG(ex.Message + ex.StackTrace);
                ADS.BeforeClose();

                if (WindowCommon.ConfirmAction("是否重启,发现异常:\n" + ex.Message + ex.Source))
                {
                    //////开启新的实例
                    System.Diagnostics.Process.Start(System.Windows.Forms.Application.ExecutablePath);
                }

                //////关闭当前实例
                System.Diagnostics.Process.GetCurrentProcess().Kill();
            }
        }