using DemoUI.Common; using System; using System.Collections.Generic; using System.Configuration; using System.Data; using System.Linq; using System.Threading.Tasks; using System.Windows; namespace DemoUI { /// /// App.xaml 的交互逻辑 /// public partial class App : Application { QMLog log = new QMLog(); private void Application_Startup(object sender, StartupEventArgs e) { try { log.WriteLogFile("正常启动", "start"); AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); Application.Current.DispatcherUnhandledException += new System.Windows.Threading.DispatcherUnhandledExceptionEventHandler(Current_DispatcherUnhandledException); AppDomain.CurrentDomain.ProcessExit += new EventHandler(CurrentDomain_ProcessExit); MainWindow win = new MainWindow(); win.Show(); } catch (Exception ex) { log.WriteLogFile(ex.ToString(), "StartupError"); MessageBox.Show("程序启动失败"); } } private void Current_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) { log.WriteLogFile(e.Exception.Message + e.Exception.StackTrace, "APPError"); } private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { Exception ex = (Exception)e.ExceptionObject; log.WriteLogFile(ex.Message + ex.StackTrace, "APPError"); } private void CurrentDomain_ProcessExit(object sender, EventArgs e) { log.WriteLogFile("程序关闭", "start"); } } }