C#未捕获异常处理方法
来源:互联网 发布:java 引号处理 编辑:程序博客网 时间:2024/06/14 20:04
C#经常会因为未捕获的异常而造成应用程序崩溃,以下是解决方法:
1.WPF捕获
Application.Current.DispatcherUnhandledException += new System.Windows.Threading.DispatcherUnhandledExceptionEventHandler(Current_DispatcherUnhandledException); void Current_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) { MessageBox.Show(e.Exception.Message + "\r\n" + e.Exception.StackTrace, "系统信息"); }
2.winform捕获
System.Windows.Forms.Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException); System.Windows.Forms.Application.SetUnhandledExceptionMode(System.Windows.Forms.UnhandledExceptionMode.CatchException); AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { MessageBox.Show(((Exception)e.ExceptionObject).Message + "\r\n" + ((Exception)e.ExceptionObject).StackTrace, "系统信息"); } void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e) { MessageBox.Show(e.Exception.Message + "\r\n" + e.Exception.StackTrace, "系统信息"); }
- C#未捕获异常处理方法
- C#未捕获异常处理方法
- android未捕获异常的处理方法
- C#处理WindowForm程序中未捕获的异常
- .net未捕获异常处理
- SetUnhandledExceptionFilter处理未捕获异常
- SetUnhandledExceptionFilter处理未捕获异常
- android 处理未捕获异常
- andoid处理未捕获异常
- java处理未捕获异常
- window未捕获异常处理
- 未捕获异常的处理
- JAVA处理未捕获异常
- 处理Python未捕获异常
- node处理未捕获异常
- .net C# 捕获所有未捕获异常
- .Net 下未捕获异常的处理
- WPF中未捕获异常之处理
- 真正的程序员,请你站出来
- RUP
- 右键打开方式无法选择UE程序
- IAP(In App Purchase)流程总结
- log4j详解与实战
- C#未捕获异常处理方法
- ffmpeg 文档1:制作屏幕录像 指导1:制作屏幕录像 概要 电影文件有很多基本的组成
- linux kernel kbuild详解 之一
- hosts文件无法修改的问题解决方案。
- 20120221英语
- Creating Backdoors Using SQL Injection
- Android之MediaPlayer详解
- 面向服务架构十大技术与基础理论
- Web前端