private void App_Startup(object sender, StartupEventArgs e) { #if !DEBUG if (Process.GetProcessesByName("MultiRPC").Length > 1) { if (File.Exists(FileLocations.OpenFileLocalLocation)) { try { File.Delete(FileLocations.OpenFileLocalLocation); } catch { App.Logging.Application(App.Text.CouldntDelete + " " + FileLocations.OpenFileLocalLocation); } } if (e.Args.Length > 0) { File.WriteAllLines(FileLocations.OpenFileLocalLocation, new List <string> { "LOADCUSTOM", e.Args[1] }); } else { File.Create(FileLocations.OpenFileLocalLocation); } Current.Shutdown(); } else if (e.Args.Length > 1 && e.Args[0] == "-custom") { StartedWithJumpListLogic = true; _ = CustomPage.JumpListLogic(e.Args[1], true); } #endif FileWatch.Create(); SettingsPage.UIText = new List <UIText>(); GetLangFiles().ConfigureAwait(false).GetAwaiter().GetResult(); UITextUpdate().ConfigureAwait(false).GetAwaiter().GetResult(); Config = Config.Load().Result; UITextUpdate().ConfigureAwait(false).GetAwaiter().GetResult(); Logging = new Logging(); File.AppendAllText(FileLocations.ErrorFileLocalLocation, $"\r\n------------------------------------------------------------------------------------------------\r\n{Text.ErrorsFrom} {DateTime.Now.ToLongDateString()} {DateTime.Now.ToLongTimeString()}"); DispatcherUnhandledException += App_DispatcherUnhandledException; }
private void App_Startup(object sender, StartupEventArgs e) { #if !DEBUG var args = e.Args?.ToList() ?? System.Extra.Uri.GetQueryStringParameters() ?? new List <string>(); if (Process.GetProcessesByName("MultiRPC").Length > 1) { if (File.Exists(FileLocations.OpenFileLocalLocation)) { try { File.Delete(FileLocations.OpenFileLocalLocation); } catch { Logging.Application(Text.CouldntDelete + " " + FileLocations.OpenFileLocalLocation); } } if (args.Contains("-custom") && args.IndexOf("-custom") + 1 >= args.Count) { File.WriteAllLines(FileLocations.OpenFileLocalLocation, new List <string> { "LOADCUSTOM", args.ElementAt(args.IndexOf("-custom") + 1) }); } else { File.Create(FileLocations.OpenFileLocalLocation); } if (!args.Contains("--fromupdate")) { Current.Shutdown(); } } else if (args.Contains("-custom") && args.IndexOf("-custom") + 1 >= args.Count) { StartedWithJumpListLogic = true; _ = CustomPage.StartCustomProfileLogic(args.ElementAt(args.IndexOf("-custom") + 1), true); } #endif FileWatch.Create(); SettingsPage.UIText = new List <UIText>(); GetLangFiles(); Config = Config.Load(); if (Config.Debug) { try { UITextUpdate(); Logging = new Logging(); File.AppendAllText(FileLocations.ErrorFileLocalLocation, $"\r\n------------------------------------------------------------------------------------------------\r\n{Text.ErrorsFrom} {DateTime.Now.ToLongDateString()} {DateTime.Now.ToLongTimeString()}"); DispatcherUnhandledException += App_DispatcherUnhandledException; Application.Current.DispatcherUnhandledException += Current_DispatcherUnhandledException; AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException; Dispatcher.UnhandledException += Dispatcher_UnhandledException; } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Startup error", MessageBoxButton.OK, MessageBoxImage.Error); } } else { UITextUpdate(); Logging = new Logging(); File.AppendAllText(FileLocations.ErrorFileLocalLocation, $"\r\n------------------------------------------------------------------------------------------------\r\n{Text.ErrorsFrom} {DateTime.Now.ToLongDateString()} {DateTime.Now.ToLongTimeString()}"); DispatcherUnhandledException += App_DispatcherUnhandledException; } }