public static void Main(string[] args) { if (args != null && args.Length > 0) { Process[] processes = Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName); if (processes.Length > 1) { ActivationProtocolHandler.SendRequest(args); return; } } App application = new App(); application.InitializeComponent(); application.Run(); }
protected override async void OnStartup(StartupEventArgs e) { WindowsServicesManager servicesManager = new WindowsServicesManager(); servicesManager.Initialize(); ActivationProtocolHandler.Initialize(); RegistryHelpers.RegisterFileAssociation(); RegistryHelpers.RegisterURIActivationProtocol(); // Disabled for now until we can figure out why anti-virus hates it // RegistryHelpers.RegisterUninstaller(); FileLoggerHandler.Initialize(servicesManager.FileService); DispatcherHelper.RegisterDispatcher(new WindowsDispatcher(this.Dispatcher)); DialogHelper.Initialize(new WPFDialogShower()); Application.Current.DispatcherUnhandledException += Current_DispatcherUnhandledException; AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; await ChannelSession.Initialize(servicesManager); WindowsIdentity id = WindowsIdentity.GetCurrent(); ChannelSession.IsElevated = id.Owner != id.User; Logger.ForceLog(LogLevel.Information, "Application Version: " + ChannelSession.Services.FileService.GetApplicationVersion()); if (ChannelSession.IsDebug() || ChannelSession.AppSettings.DiagnosticLogging) { Logger.SetLogLevel(LogLevel.Debug); } else { Logger.SetLogLevel(LogLevel.Error); } this.SwitchTheme(ChannelSession.AppSettings.ColorScheme, ChannelSession.AppSettings.BackgroundColor, ChannelSession.AppSettings.FullThemeName); base.OnStartup(e); }
protected override void OnExit(ExitEventArgs e) { ActivationProtocolHandler.Close(); base.OnExit(e); }