469,621 Members | 1,666 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,621 developers. It's quick & easy.

"Global" exception handling

Just a short question concerning exception handling....

All of my applications contain an event handling in the Main() like this
one:

[STAThread]
static void Main()
{
// declare global exeption handler
Application.ThreadException += new
ThreadExceptionEventHandler(GlobalExceptionHandler .OnThreadException);
...
// load main form and start application
...
}

By that I am showing a special exception form to the user (with features
like "send bug report to ..."). This is for cases where I forgot a try/catch
somewhere.
Now I have to write a UserControl for an application that is out of my
control so I do not have personal influence on that code.
My UserControl is just loaded by that application, user can do several
things with it and it stays loaded all the time until the application is
closed again.

So the only entry point I have for this control is just the constructor.

How can I achieve to have a "global" exception handling just for my own
UserControl code? With Application.ThreadException I would include also the
hosting application...

Thanks in advance!
Tom


Feb 5 '08 #1
1 3248
Hello Tom,

what are u handling now, is only exception on the application level, without
taking into account different appDomains
For this u need to add AppDomain.UnhandledException handlin'

---
WBR,
Michael Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo
TBJust a short question concerning exception handling....
TB>
TBAll of my applications contain an event handling in the Main() like
TBthis one:
TB>
TB[STAThread]
TBstatic void Main()
TB{
TB// declare global exeption handler
TBApplication.ThreadException += new
TBThreadExceptionEventHandler(GlobalExceptionHandl er.OnThreadException
TB);
TB...
TB// load main form and start application
TB...
TB}
TBBy that I am showing a special exception form to the user (with
TBfeatures like "send bug report to ..."). This is for cases where I
TBforgot a try/catch somewhere.
TB>
TBNow I have to write a UserControl for an application that is out of
TBmy
TBcontrol so I do not have personal influence on that code.
TBMy UserControl is just loaded by that application, user can do
TBseveral
TBthings with it and it stays loaded all the time until the
TBapplication is
TBclosed again.
TBSo the only entry point I have for this control is just the
TBconstructor.
TB>
TBHow can I achieve to have a "global" exception handling just for my
TBown UserControl code? With Application.ThreadException I would
TBinclude also the hosting application...
TB>
TBThanks in advance!
TBTom
Feb 5 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

11 posts views Thread by mrbog | last post: by
1 post views Thread by Chris Stromberger | last post: by
9 posts views Thread by Javaman59 | last post: by
2 posts views Thread by Steve | last post: by
5 posts views Thread by Graham Charles | last post: by
3 posts views Thread by Ernesto | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.