• wpf 全局异常捕获处理


    /// <summary>
        /// App.xaml 的交互逻辑
        /// </summary>
        public partial class App : Application
        {
            private const string Tag = nameof(App);
            public App() 
            {
                Dispatcher.UnhandledException += Dispatcher_UnhandledException;
                DispatcherUnhandledException += App_DispatcherUnhandledException;
                AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
                
            }
    
            private void Dispatcher_UnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
            {
                Logger.Fatal(Tag,"",e.Exception);
            }
    
            private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
            {
                var exception = e.ExceptionObject as Exception;
                var terminatingMessage = e.IsTerminating ? " The application is terminating." : string.Empty;
                var exceptionMessage = exception?.Message ?? "An unmanaged exception occured.";
                var message = string.Concat(exceptionMessage, terminatingMessage);
                Logger.Fatal(Tag, message, exception);
            }
    
            private void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
            {
                Logger.Fatal(Tag, "", e.Exception);
            }
        }
    --------------------------------------------------------------------------------------------------------------------------------------------------

  • 相关阅读:
    java程序员裸机配置
    安装库
    自定义脚本模板
    Oracle数据库触发器简单案例
    Oracle数据库按正则切割字符串
    Oracle查询一张表的所有字段
    Oracle数据库系统表
    Oracle设置最大连接数
    Oracle博客参考教程
    区间dp [H
  • 原文地址:https://www.cnblogs.com/bruce1992/p/14124776.html
Copyright © 2020-2023  润新知