-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);
}
你在哪裏得到異常? –
添加句子以顯示部分代碼。請詳細提供您的問題 –
這是一個非常差的問題,您沒有提供詳細信息 –