Catching unhandled exceptions in application

S

Shravan

Hi,
Does anybody know how to catch unhandled exceptions in
an application.
I have tried using

AppDomain.UnhandledException Event
Application.ThreadException Event

but they were not catching unhandled exceptions always.
There are not working in some cases.

Anybody pl reply

Thanks,
Shravan.
 
C

Cowboy \(Gregory A. Beamer\)

My advice would be to find the problem area and add a try... catch. I know
of no way to have a completely unhandled exception caught, except by the
system (ugly error message). This does not mean it is impossible, but that
you might end up with far more work trying to nab this functionality from
the CLR than it is worth.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

**********************************************************************
Think Outside the Box!
**********************************************************************
 
B

Brian L. Gorman

Shravan said:
Hi,
Does anybody know how to catch unhandled exceptions in
an application.

You have to use try..catch to handle exceptions. If you are getting an
error message based on an unhandled exception, simply put your code in the
following:

try
{
//insert the code here (and If this means the entire procedure, then so
be it)
}
catch (System.Exception ex)
{
//you will want to learn more about try..catch syntax because the order
of error goes from specific to less specific...this catches any system
error, period
//however you might want to code specifically for a data error and do
something like catch(System.Data.Exception ex) ...
MessageBox.Show("SYSTEM ERROR: " + ex.Message.ToString());
}

Good Luck,
Brian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top