473,799 Members | 2,999 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

catch all unhandled exeptions does not work for all computers.

I am using:

Application.Thr eadException += new
System.Threadin g.ThreadExcepti onEventHandler( Application_Thr eadException);

But, my function is not run when an exception is thrown on another
computer running WinXP SP2, and I have no idea why. Instead, the
Windows error report screen appears. Isn't the above supposed to work
no matter what? What am I doing wrong?

Zytan

May 8 '07 #1
17 2186
Zytan <zy**********@g mail.comwrote:
I am using:

Application.Thr eadException += new
System.Threadin g.ThreadExcepti onEventHandler( Application_Thr eadException);

But, my function is not run when an exception is thrown on another
computer running WinXP SP2, and I have no idea why. Instead, the
Windows error report screen appears. Isn't the above supposed to work
no matter what? What am I doing wrong?
Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
May 8 '07 #2
Hello Zytan,

What kind of applocation? winform based?
Try to use AppDomain.Curre ntDomain.Unhand ledException handling

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

"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

ZI am using:
Z>
ZApplication.Th readException += new
ZSystem.Threadi ng.ThreadExcept ionEventHandler (Application_Th readExcept
Zion);
ZBut, my function is not run when an exception is thrown on another
Zcomputer running WinXP SP2, and I have no idea why. Instead, the
ZWindows error report screen appears. Isn't the above supposed to
Zwork no matter what? What am I doing wrong?
Z>
ZZytan
Z>
May 8 '07 #3
Here is a short article that summarizes a lot of this, including Registry
setting that controls the JIT Debugger Windows Error screen popup:

http://www.eggheadcafe.com/articles/20051205.asp

Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"Zytan" wrote:
I am using:

Application.Thr eadException += new
System.Threadin g.ThreadExcepti onEventHandler( Application_Thr eadException);

But, my function is not run when an exception is thrown on another
computer running WinXP SP2, and I have no idea why. Instead, the
Windows error report screen appears. Isn't the above supposed to work
no matter what? What am I doing wrong?

Zytan

May 9 '07 #4
Could you post a short but complete program which demonstrates the
problem?
No, I cannot, since I don't have access to the machines on which my
code does not work. I think the single line of code that I provided
is all that is required to make this work, and for some reason that
line of code does not do anything on certain WinXP machines. I am
dumbfounded that the results vary.

Zytan

May 9 '07 #5
What kind of applocation? winform based?

Yes, a Windows Form.
Try to use AppDomain.Curre ntDomain.Unhand ledException handling
Michael, I tried this, and rejected this for two reasons:
1. When in the debugger, this catch will run its own code before the
debugger has a chance to catch the exception itself. It gets in the
debugger's way.
2. When in release, Windows catches the error first. This is the most
important job for it to do, and it doesn't do it.

Zytan

May 9 '07 #6
Here is a short article that summarizes a lot of this, including Registry
setting that controls the JIT Debugger Windows Error screen popup:

http://www.eggheadcafe.com/articles/20051205.asp
Thanks, Peter, I will read this now.

Zytan

May 9 '07 #7
Here is a short article that summarizes a lot of this, including Registry
setting that controls the JIT Debugger Windows Error screen popup:

http://www.eggheadcafe.com/articles/20051205.asp
Unfortunately, this articles just enumerates all ways to catch
exceptions. It doesn't summarize anything else, like about how they
work, which one is better, in which situations one is better, which
one could be used in deployment, etc. All it is are methods to help
the developer catch the problem on her own machine.

So, I'm still at square one, trying to determine why the following
code 'fires' on some WinXP machines (mine), but not on others (that I
unfortunately can't get my hands on, at the moment). It's hard to
beta test something that is not consistent.

Application.Thr eadException += new
System.Threadin g.ThreadExcepti onEventHandler( Application_Thr eadException);

Zytan

May 9 '07 #8
Well, as the other posters (and the article) indicated, there are only two
handlers to catch an unhandled exception event:

Thread.GetDomai n().UnhandledEx ception += new
UnhandledExcept ionEventHandler (Application_Un handledExceptio n);

Application.Thr eadException += new ThreadException EventHandler(
Application_Thr eadException );

if you have them both wired up correctly in your application, and there is
an unhandled exception, then depending on whether it occured on the main
thread or elsewhere, one of these is going to sqwawk.

Bear in mind these are EVENT handlers, not "exception" handlers. Once you
have an unhandled exception, your deal is gone - these are just there to give
you a last chance to perform cleanup, log the event, etc.
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"Zytan" wrote:
Here is a short article that summarizes a lot of this, including Registry
setting that controls the JIT Debugger Windows Error screen popup:

http://www.eggheadcafe.com/articles/20051205.asp

Unfortunately, this articles just enumerates all ways to catch
exceptions. It doesn't summarize anything else, like about how they
work, which one is better, in which situations one is better, which
one could be used in deployment, etc. All it is are methods to help
the developer catch the problem on her own machine.

So, I'm still at square one, trying to determine why the following
code 'fires' on some WinXP machines (mine), but not on others (that I
unfortunately can't get my hands on, at the moment). It's hard to
beta test something that is not consistent.

Application.Thr eadException += new
System.Threadin g.ThreadExcepti onEventHandler( Application_Thr eadException);

Zytan

May 9 '07 #9
Maybe I'll just have to bite
the bullet, and lose my debugger's ability to grab exceptions, and let
my code always catch it, if that's what I need to do to ensure other
computers in a release build will catch them, as well.
Hm, I'll just NOT run the one that doesn't work if I'm in debug mode.
That way the release mode can catch everything and anything it wants,
and it should. And in debug mode, hey, I don't even need any of these
things running, actually, if the debugger is there, since it always
catches everything (right?).

Zytan

May 9 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3385
by: valued customer | last post by:
Is there a more concise way to do something like the the desired code below? The gripe is with the try-catch syntax. It takes *way* too many lines of code to evaluate a conditional expression when zero or more parts of the conditional expression may trigger an error. In this case, the trigger is a call to a non-defined (null) object. In other words, how can you do a more simple 'try' statement
2
1939
by: Ralph Krausse | last post by:
I created a try/catch/finally but when an expection is thrown, the catch does not handle it... (I know this code is wrong, I want to force the error for this example) try { DataSet ds = new DataSet(); string strID = ds.Tables.Rows.ToString(); }
2
1118
by: Solution Seeker | last post by:
Hi, I have a Problem when i try to put a Try Catch Block Outside all the Functions in a Class. But in .Net, it throws an error. I like to catch all the Unhandled Exception that occured inside a Class so I need to Put a TRY CATCH Block from the Next Line from where the Class starts. I need to Achieve the Above Scenerio.
5
3405
by: Simon Tamman {Uchiha Jax} | last post by:
Now this is bugging me. I just released software for a client and they have reported an unhandled stack overflow exception. My first concern is that the entirity of the UI and any threaded operations are all within Try Catches to help me locate the problem and the origination of any problem by specifiying an error code in the "Catch" section. So theoretically this shouldn't have been possible (at which point we all say "yeah,...
3
1819
by: Nick | last post by:
Hi there, This probably wont make much sense but I'm getting an unhandled exception being thrown in the following line... Try While True Redraw control as necessary End While Catch ex as Exception <<< Here!
2
1919
by: CodeSlayer | last post by:
Hi all, This one really has me and the other .Net developers at my work stumped. I have an application that is doing the following: 1 - attempt to validate that user can create a windows task via COM interops 2 - an exception is thrown because user doesn't exist 3 - Exception is caught by calling code shown below:
2
1864
by: Fernando Chilvarguer | last post by:
I have a very simple test page that the only thing it does is render a control. This control generates and throws an error. I need to catch the error on my ASPX page but I can't figure out where to put my try/catch block to make it work. Any ideas?
2
2748
by: pack | last post by:
Is "catch" in C# going to catch all exception, or it just catch the exceptions induced by "throw"? Will it also catch those "structured exceptions" that could be either from system modules or other DLL or COM objects of native code? If seeing a dialog of this: "Unhandled exception at 0x8f345690 in vsdv.exe: 0xC0000005. Access violation reading location 0x02313000."
6
1530
by: rhaazy | last post by:
I am looking for some feedback on using try catch statements. Usually when I start a project I use them for everything, but stop using them as often after the "meat n' potatos" of the project is finished. I am thinking it would be useful to at least have a blanket try-catch to surround all of the code, and add more to aid in debugging and catching specific exceptions. I want to change my habits but before I do I wanted to see if anyone...
0
9546
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
10491
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
10268
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
10031
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7571
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5593
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4146
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
2
3762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2941
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.