• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 742
  • Last Modified:

Application.ThreadException not getting called

I am using .NET 2.0 SDK Beta and trying to trap thread exceptions in order to handle 'unhandled' exceptions and log them. I am running the following line in my Main method:

Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);

The method simply does a MessageBox.Show in order to indicate that it was called. However, it never does get called, instead throwing whatever exception is throw (I have hardcoded one to be thrown). Am I doing something wrong? Additional step, perhaps?

1 Solution
This will not catch exceptions that are thrown from the application's main thread.  To do this, you must wrap your Application.Run statement in a try...catch block.
athomas4219Author Commented:
What exceptions will that catch? Exceptions thrown by any OTHER threads?

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now