-1
不能例外后执行的代码,它是印刷为什么这个UnhandledException事件处理程序不工作?
CCCCC
但不打印
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);
}
你在哪里得到异常? –
添加句子以显示部分代码。请详细提供您的问题 –
这是一个非常差的问题,您没有提供详细信息 –