Ejemplo n.º 1
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            SettingsPath = e.Args.FirstOrDefault();

            AppDomain.CurrentDomain.UnhandledException += (s, e) =>
                                                          LogUnhandledException((Exception)e.ExceptionObject);

            DispatcherUnhandledException += (s, e) =>
            {
                LogUnhandledException(e.Exception);

                if (e.Exception is not COMException)
                {
                    e.Handled = true;
                }
            };

            TaskScheduler.UnobservedTaskException += (s, e) =>
            {
                LogUnhandledException(e.Exception);

                if (e.Exception.InnerException is not COMException)
                {
                    e.SetObserved();
                }
            };
        }
Ejemplo n.º 2
0
        private void App_Startup(object sender, StartupEventArgs e)
        {
            // Hook general uncaught exception events to show user. (this won't help with some of the CLR/pinvoke errors that might occur)
            Dispatcher.UnhandledException += (s, e) =>
            {
                e.Handled = true;
                ShowUnhandledException(e.Exception, "Dispatcher.UnhandledException");
            };

            TaskScheduler.UnobservedTaskException += (s, e) =>
            {
                e.SetObserved();
                ShowUnhandledException(e.Exception, "TaskScheduler.UnobservedTaskException");
            };
        }
Ejemplo n.º 3
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            var window = new MainWindow();

            IIoCService iocService = new IoCService
            {
                RegisterComponents = (ioc) =>
                {
                    ioc.RegisterType <ESPMessageService>().As <IESPMessageService>();
                }
            };

            iocService.Build();
            iocService.Resolve <IAppService>().SetTheme(ThemeType.Light);
            window.DataContext = iocService.Resolve <IMainWindowViewModel>();
            window.Show();

            iocService.Resolve <INavigationService>().NavigateTo <FindESPViewModel, FindESPView>();

            AppDomain.CurrentDomain.UnhandledException += (s, e) => iocService.Resolve <IAppService>().ProcessException((Exception)e.ExceptionObject, "Domain exception");
            Dispatcher.UnhandledException += (s, e) =>
            {
                e.Handled = true;
                iocService.Resolve <IAppService>().ProcessException(e.Exception, "Dispatcher exception");
            };
            TaskScheduler.UnobservedTaskException += (s, e) =>
            {
                if (e.Exception != null)
                {
                    iocService.Resolve <IAppService>().ProcessException(e.Exception, "Unobserved exception");
                    e.SetObserved();
                }
            };
        }