protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); this.DispatcherUnhandledException += App_DispatcherUnhandledException; var proc = System.Diagnostics.Process.GetProcessesByName("WordAndImgOperationApp"); //两个进程的话就杀掉一个 if (proc.Length > 1) { Application.Current.Dispatcher.Invoke((Action)(() => Application.Current.Shutdown())); return; } try { WordAndImgAppInfo info = new WordAndImgAppInfo(); info.Path = AppDomain.CurrentDomain.BaseDirectory + "WordAndImgOperationApp.exe"; string infos = string.Format(@"{0}\WordAndImgAppInfo.xml", Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\WordAndImgOCR\\LoginInOutInfo\\"); DataParse.WriteToXmlPath(JsonConvert.SerializeObject(info), infos); } catch (Exception ex) { } try { UtilSystemVar.UrlStr = ConfigurationManager.AppSettings["UrlStr"].ToString() + ConfigurationManager.AppSettings["APIVersion"].ToString() + "/"; } catch { } BootStrapper(); }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); this.DispatcherUnhandledException += App_DispatcherUnhandledException; var proc = System.Diagnostics.Process.GetProcessesByName("WordAndImgOperationApp"); //两个进程的话就杀掉一个 if (proc.Length > 1) { Application.Current.Dispatcher.Invoke((Action)(() => Application.Current.Shutdown())); return; } StartService(); try { WordAndImgAppInfo info = new WordAndImgAppInfo(); info.Path = AppDomain.CurrentDomain.BaseDirectory + "WordAndImgOperationApp.exe"; string infos = string.Format(@"{0}\WordAndImgAppInfo.xml", Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\WordAndImgOCR\\LoginInOutInfo\\"); DataParse.WriteToXmlPath(JsonConvert.SerializeObject(info), infos); } catch (Exception ex) { } MainWindow window = new MainWindow(); window.Show(); }