diff --git a/App.xaml.cs b/App.xaml.cs index f90af95..0303e14 100644 --- a/App.xaml.cs +++ b/App.xaml.cs @@ -13,5 +13,54 @@ namespace formula_manage /// public partial class App : Application { + public App() + { + this.Startup += new StartupEventHandler(App_Startup); + this.DispatcherUnhandledException += new System.Windows.Threading.DispatcherUnhandledExceptionEventHandler(App_DispatcherUnhandledException); + } + + System.Threading.Mutex mutex; + void App_Startup(object sender, StartupEventArgs e) //程序只允许启动一次 + { + bool ret; + mutex = new System.Threading.Mutex(true, "ElectronicNeedleTherapySystem", out ret); + if (!ret) + { + MessageBox.Show("SUNLIGHT:单据管理已启动"); + Environment.Exit(0); + } + } + + protected override void OnStartup(StartupEventArgs e) //跟踪报错信息 + { + base.OnStartup(e); + //UI线程的异常捕捉 + this.DispatcherUnhandledException += App_DispatcherUnhandledException; + } + + private void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) + { + + e.Handled = true; + if (e.Exception.InnerException == null) + { + MessageBox.Show("发生了一个无法处理的错误!请联系SUNLIGHT处理!" + Environment.NewLine + // + "(2)错误源:" + e.Exception.Source + Environment.NewLine + + "详细信息:" + e.Exception.Message + Environment.NewLine + // + "(4)报错区域:" + e.Exception.StackTrace + ); + } + else + { + MessageBox.Show("发生了一个无法处理的错误!请联系SUNLIGHT处理!" + Environment.NewLine + // + "(2)错误源:" + e.Exception.InnerException.Source + Environment.NewLine + + "错误信息:" + e.Exception.Message + Environment.NewLine + // + "(4)详细信息:" + e.Exception.InnerException.Message + Environment.NewLine + // + "(5)报错区域:" + e.Exception.InnerException.StackTrace + ); + } + + + } } } diff --git a/Windows/Sql.xaml b/Windows/Sql.xaml index e7722ff..cfac13f 100644 --- a/Windows/Sql.xaml +++ b/Windows/Sql.xaml @@ -24,6 +24,7 @@ -