您的位置:首页 > 其它

Winform 统一捕获异常,捕获未处理异常

2014-07-31 08:54 471 查看
using System;
using System.Windows.Forms;

//注册全局的异常处理程序,扑获产生的异常。
namespace Zhengzuo.CSharpCode
{
static class Program
{

/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);

Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new FormMain());
}

static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
{
throw new Exception("The method or operation is not implemented.");
}

static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
throw new Exception("The method or operation is not implemented.");
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: