控制台、WinForm程序可以用以下方法做全局捕获
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { var error = (Exception)e.ExceptionObject; Console.WriteLine("MyHandler caught : " + error.Message); Console.Read(); Environment.Exit(0); }