private static void ProcessError(Exception ex) { //TODO: process error... //... var message = "An unexpected error has occurred. Application will be closed"; try { var exceptionMessage = ex?.Message ?? message; logger.Fatal(exceptionMessage); var dialogService = new Services.DialogService(); var vm = new ViewModels.Dialogs.MessageBoxViewModel(exceptionMessage, "Error", MessageBoxButton.OK); var result = dialogService.ShowDialog(vm); } catch (Exception ex1) { logger.Error(ex1); MessageBox.Show(message, "Error", MessageBoxButton.OK); } }
protected override void OnStartup(StartupEventArgs e) { logger.Debug("OnStartup(...) " + string.Join(" ", e.Args)); var args = e.Args; var appModel = ConfigManager.LoadConfigurations(); //TODO: validate... if (!appModel.Init()) { //... // Reset config... } // SystemMan.Initialize(); ServiceLocator.RegisterInstance(appModel); // ServiceLocator.RegisterSingleton(GalaSoft.MvvmLight.Messaging.Messenger.Default); //х.з зачем это... var dialogService = new Services.DialogService(); ServiceLocator.RegisterInstance <Interfaces.IDialogService>(dialogService); var mainViewModel = new ViewModels.Dialogs.MainViewModel(appModel); Views.AppWindow mainWindow = new Views.AppWindow(mainViewModel) { Title = "Polywall Streamer", }; dialogService.Register(mainViewModel, mainWindow); dialogService.Show(mainViewModel); base.OnStartup(e); }