Exception handling at the GUI boundary

  • Thread starter Thread starter Bevo
  • Start date Start date
B

Bevo

a) My cMyMainForm throws an unhandled exception (in my
case a third party component throws a SEHException when
hovering the mouse pointer over it). I want to display my
own dialog box instead of .NET's and take the system down
gracefully.

b) I've tried the UnhandledException event but I cant
find any functionality that allows me to suppress the
exception dialog, in fact the exception dialog is
displayed BEFORE the event is fired.

c) I could always try/catch the Application.Run method in
my Main method but when I'm inside the catch my form
object is long gone so I cant show ANY dialog.

Any suggestions on how to accomplish a)?
 
Bevo said:
a) My cMyMainForm throws an unhandled exception (in my
case a third party component throws a SEHException when
hovering the mouse pointer over it). I want to display my
own dialog box instead of .NET's and take the system down
gracefully.
b) I've tried the UnhandledException event but I cant
find any functionality that allows me to suppress the
exception dialog, in fact the exception dialog is
displayed BEFORE the event is fired.

c) I could always try/catch the Application.Run method in
my Main method but when I'm inside the catch my form
object is long gone so I cant show ANY dialog.

Any suggestions on how to accomplish a)?/

You need to install event handlers for both of these events:

Application.ThreadException -- solves a)
AppDomain.UnhandledException -- for non-CLS-Compliant exceptions

Cheers,
 
Back
Top