1.1 --- a/Program.cs Fri Apr 02 16:05:07 2010 +0000
1.2 +++ b/Program.cs Mon Apr 05 15:31:19 2010 +0000
1.3 @@ -48,6 +48,11 @@
1.4 [STAThread]
1.5 public static void Main() {
1.6 #if !DEBUG
1.7 + Application.ThreadException +=
1.8 + new ThreadExceptionEventHandler(Application_ThreadException);
1.9 + Application.SetUnhandledExceptionMode(
1.10 + UnhandledExceptionMode.CatchException);
1.11 +
1.12 AppDomain.CurrentDomain.UnhandledException +=
1.13 new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
1.14 #endif
1.15 @@ -62,13 +67,31 @@
1.16 }
1.17 }
1.18
1.19 + private static void ReportException(Exception e) {
1.20 + CrashReportForm form = new CrashReportForm();
1.21 + form.Exception = e;
1.22 + form.ShowDialog();
1.23 + }
1.24 +
1.25 + public static void Application_ThreadException(object sender,
1.26 + ThreadExceptionEventArgs e)
1.27 + {
1.28 + try {
1.29 + ReportException(e.Exception);
1.30 + } catch {
1.31 + } finally {
1.32 + Application.Exit();
1.33 + }
1.34 + }
1.35 +
1.36 public static void CurrentDomain_UnhandledException(object sender,
1.37 UnhandledExceptionEventArgs args)
1.38 {
1.39 - CrashReportForm form = new CrashReportForm();
1.40 - form.Exception = (Exception)args.ExceptionObject;
1.41 - form.ShowDialog();
1.42 - Environment.Exit(0);
1.43 + try {
1.44 + Exception e = args.ExceptionObject as Exception;
1.45 + if (e != null)
1.46 + ReportException(e);
1.47 + } catch { }
1.48 }
1.49 }
1.50 }