//捕获当前未绑定异常
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
//捕获线程异常
Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);
static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
{
Exception exp = e.Exception;
//todo:记录异常
}
static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
Exception exp = (Exception)e.ExceptionObject;
//todo:记录异常
}