异常后无法执行代码,正在打印
cccc
但不打印
AFTER_EXCEPTION
代码显示捕获的异常然后存在。
static void Main(string[] args)
{
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(MyHandler); // using System.Diagnostics;
// Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(OnThreadException);
Process p = Process.GetProcessById(1000);
Console.WriteLine("AFTER_EXCEPTION");
Console.ReadLine();
}
static void MyHandler(object sender, UnhandledExceptionEventArgs args)
{
Console.WriteLine("cccc");
Exception temp = (Exception)args.ExceptionObject;
Console.WriteLine("MyHandler caught : " + temp.Message);
Console.WriteLine("MyHandler caught : " + temp.TargetSite);
}