[Mono-list] mono_runtime_invoke not catching exceptions?

efontana eric at fontanas.net
Tue Feb 21 21:26:26 UTC 2012


Bingo!  Added the following code causes the exception to be thrown, and
caught in Mono

  //throw new Exception("Badd shit");
      Application.EnableVisualStyles();
      Application.SetCompatibleTextRenderingDefault(false);

      Application.ThreadException += new
System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
      // Set the unhandled exception mode to force all Windows Forms errors
to go through
      // our handler.
     
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);

      AppDomain.CurrentDomain.UnhandledException += new
UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
      try
      {
        Application.Run(new Form1());
      }
      catch (Exception ex)
      {
        Console.WriteLine("re-Throw: {0}", ex.Message);
        throw ex;
      }

 static void Application_ThreadException(object sender,
System.Threading.ThreadExceptionEventArgs e)
    {
      Console.WriteLine("Caught ex2: {0}", e.Exception.Message);
      throw e.Exception;

      Application.Exit();
    }

    static void CurrentDomain_UnhandledException(object sender,
UnhandledExceptionEventArgs e)
    {
      Exception ex = (Exception)e.ExceptionObject;
      Console.WriteLine("Caught ex: {0}", ex.Message);
      Application.Exit();
    }


--
View this message in context: http://mono.1490590.n4.nabble.com/mono-runtime-invoke-not-catching-exceptions-tp4407688p4408378.html
Sent from the Mono - General mailing list archive at Nabble.com.


More information about the Mono-list mailing list