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.");
}
}
}
Winform 统一捕获异常,捕获未处理异常
最新推荐文章于 2024-01-01 10:28:21 发布