chr
2025-02-24 104cad5ee53eb05d3a89d508a029425726ae89ae
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using HMI.UI.Util;
using System.Windows.Markup;
using log4net;
using Panuon.WPF.UI;
 
namespace WPFProject
{
    /// <summary>
    /// App.xaml 的交互逻辑
    /// </summary>
    public partial class App : Application
    {
        private ILog log;
        public App()
        {
            log = LogManager.GetLogger("APP");
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
        }
 
        private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            log.Error("未知异常", e.ExceptionObject as Exception);
            Dispatcher.Invoke(() =>
            {
                MsgBoxHelper.ErrorMessage(Current.MainWindow, $"发生未知异常!程序即将关闭", "错误", MessageBoxButton.OK,
                    MessageBoxIcon.Error, DefaultButton.YesOK, 5);
            });
        }
 
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            LoadingWindow window = new LoadingWindow();
            window.Show();
        }
    }
}