App.xaml.cs

(完整代码) 1KB

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Windows;
using System.Windows.Threading;
/// <summary>
/// 文件名:App.xaml 的交互逻辑
/// 文件功能描述:操作异常提示信息
/// 版权所有:Copyright (C) liangjw
/// 创建标识:2013.08.02
/// 修改描述:
/// </summary>
namespace SqlInsert
{
    public partial class App : Application
    {

        public App()
        {
            this.DispatcherUnhandledException += new DispatcherUnhandledExceptionEventHandler(Application_DispatcherUnhandledException);
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
        }

        void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            try
            {
                Exception ex = e.ExceptionObject as Exception;
                string errorMsg = "非WPF窗体线程异常 : \n\n";
                MessageBox.Show(errorMsg + ex.Message + Environment.NewLine + ex.StackTrace);
            }
            catch
            {
                MessageBox.Show("不可恢复的WPF窗体线程异常,应用程序将退出!");
            }
        }

        void Application_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
        {

            try
            {

                string errorMsg = "WPF窗体线程异常 : \n\n";
                MessageBox.Show(errorMsg);
                e.Handled = true;
            }
            catch
            {
                MessageBox.Show("不可恢复的WPF窗体线程异常,应用程序将退出!");
            }
        }

    }
}

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。