WPF未知异常捕获(全局)

 public partial class App : Application
    {

        protected override void OnStartup(StartupEventArgs e)
        {
            AppDomain.CurrentDomain.UnhandledException +=
             new UnhandledExceptionEventHandler(UnhandledExceptionEventHandler);
        }

        private void UnhandledExceptionEventHandler(object sender, UnhandledExceptionEventArgs e)
        {
            throw new NotImplementedException();
        }
    }

在文件的启动类中添加如上代码;在UnhandledExceptionEventHandler方法中进行异常的处理

posted @ 2017-12-04 16:36  五好青年,勇往直前  阅读(342)  评论(0编辑  收藏  举报