473,837 Members | 1,646 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"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.Thr eadException += new
ThreadException EventHandler(Gl obalExceptionHa ndler.OnThreadE xception);
...
// 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.Thr eadException I would include also the
hosting application...

Thanks in advance!
Tom


Feb 5 '08 #1
1 3387
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.Unhan dledException 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.T hreadException += new
TBThreadExcepti onEventHandler( GlobalException Handler.OnThrea dException
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.Thr eadException 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
2713
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 called $glb. So, every function so far looks like this: function something() { global $glb; }
1
1838
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
2692
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" seems to be recognised by Access in at least three cases:- 1) "Global Const". Recently someone in this group helped me resolve a problem, and it involved the use of a Global Const. By Googling "Global Const", I got plenty of hits -- but they...
9
2498
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 is, do "global" and "::" always go together? Is there any other use for these operators, than as a pair? TIA,
2
3719
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 do I ensure that changes made to the "Global.asax.vb" file are immediately reflected in the "Global.asax" file? After I change to the "Global.asax.vb" file, the "Global.asax" file date modified does not change and I do not see the updated values...
5
2416
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 transition my apps from VB6 to VB.NET, I'm curious about the best, most efficient way to include those in my application. Here's what I'm considering: 1. My gut reaction is to compile these routines into separate class libraries...
3
2190
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 anyExceptionOccurs(): if myCondition: print "Here's my global exception message"
2
3132
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 modules do not explicitly import TestRunError. TestRunError is raised in various places throughout the modules.
4
3414
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 time. Here is a snippet of example code: def foo (a): global p global a p = a + 3 #here "a" will be reference to the global one a = 1
0
9846
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
9683
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10883
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10579
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7007
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5674
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5852
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4479
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3126
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.