private void Application_Startup(object sender, StartupEventArgs e) { SetLoggerConfiguration(); Dispatcher.UnhandledException += (object sender, DispatcherUnhandledExceptionEventArgs e) => UnhandledException(e.Exception, LogLevel.Error); // AppDomain.CurrentDomain.FirstChanceException += (object sender, FirstChanceExceptionEventArgs e) => UnhandledException(e.Exception, LogLevel.Info); AppDomain.CurrentDomain.UnhandledException += (object sender, UnhandledExceptionEventArgs e) => UnhandledException(e.ExceptionObject as Exception, LogLevel.Error); TaskScheduler.UnobservedTaskException += (object sender, UnobservedTaskExceptionEventArgs e) => UnhandledException(e.Exception, LogLevel.Error); var globalContext = ApplicationContext.Global; globalContext.AddFromConfiguration(typeof(CoreConfiguration)); globalContext.AddFromConfiguration(typeof(ApiConfiguration)); globalContext.AddFromConfiguration(typeof(AppConfiguration)); globalContext.Discover(GetOrLoadAssemblies("XOutput.Core", "XOutput.Api", "XOutput.Devices", "XOutput.Emulation", "XOutput.Server")); var configurationManager = globalContext.Resolve <ConfigurationManager>(); var mainWindow = ApplicationContext.Global.Resolve <MainWindow>(); MainWindow = mainWindow; var hidGuardianManager = globalContext.Resolve <HidGuardianManager>(); hidGuardianManager.ClearPid(Process.GetCurrentProcess().Id); string settingsPath = Path.Combine(Directory.GetCurrentDirectory(), "config", "server.json"); if (true) { try { hidGuardianManager.SetPid(Process.GetCurrentProcess().Id); } catch (Exception) { globalContext.Resolve <NotificationService>().Add(Notifications.HidGuardianRegistry, null, NotificationTypes.Warning); } } server = globalContext.Resolve <Server.Server>(); server.GetHost().StartAsync(); }