473,396 Members | 1,990 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

"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 3371
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: mrbog | last post by:
I have an array/hash that stores path information for my app. As in, what directory this is in, what directory that's in, what the name of the site is, what the products are called, etc. It's...
1
by: Chris Stromberger | last post by:
This doesn't seem like it should behave as it does without using "global d" in mod(). d = {} def mod(): d = 3 mod() print d
7
by: Lyn | last post by:
Hi and Season's Greetings to all. I have a question regarding the use of a qualifier word "Global". I cannot find any reference to this in Access help, nor in books or on the Internet. "Global"...
9
by: Javaman59 | last post by:
I saw in a recent post the :: operator used to reach the global namespace, as in global::MyNamespace I hadn't seen this before, so looked it up in MSDN, which explained it nicely. My question...
2
by: Steve | last post by:
I am new to this newsgroup & to .NET in general. I have been playing around with Visual Studio .NET, building and rendering web pages using VB "code behind" files. My problem / question is; How...
5
by: Graham Charles | last post by:
I've got several generic "library" routines that are used by many of my controls & applications (things like string manipulation, generic error handling, an "about" box generator, etc.). As I...
3
by: Ernesto | last post by:
Within the scope of one Python file (say myFile.py), I'd like to print a message on ANY exception that occurs in THAT file, dependent on a condition. Here's the pseudocode: if...
2
by: jmike | last post by:
I'm using some legacy code that has a user-defined exception in it. The top level program includes this line from TestRunError import * It also imports several other modules. These other...
4
ChrisWang
by: ChrisWang | last post by:
Hi, I am having trouble understanding the use of 'global' variables I want to use a global variable with the same name as a parameter of a function. But I don't know how to use them at the same...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.