Link to home
Start Free TrialLog in
Avatar of rmmarsh
rmmarshFlag for United States of America

asked on

Some exceptions not being caught by handlers

I have this code in my Program.cs file:
 
// Add the event handler for handling UI thread exceptions to the event.
              Application.ThreadException += new ThreadExceptionEventHandler(mainForm.Form1_UIThreadException);

                // Add the event handler for handling non-UI thread exceptions to the event. 
              AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(mainForm.CurrentDomain_UnhandledException);

                Application.Run(new mainForm());

Open in new window


When I throw an exception like this: throw new InvalidConstraintException();
I get an error message that the exception was unhandled.  (there is code to handle the exception, but it's not being called)

What am I doing wrong?
ASKER CERTIFIED SOLUTION
Avatar of Jacques Bourgeois (James Burger)
Jacques Bourgeois (James Burger)
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rmmarsh

ASKER

Thank you so much... works like a champ!