private void Application_Startup(object sender, StartupEventArgs e) { var serviceManager = new ServiceManager(); if (!serviceManager.Startup(e.Args)) { serviceManager.Dispose(); serviceManager = null; this.Shutdown(); } else { this.StartupUri = new Uri("Windows/MainWindow.xaml", UriKind.Relative); _serviceManager = serviceManager; } }