473,397 Members | 2,068 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,397 software developers and data experts.

Vanishing Exceptions

My unhandled exceptions seem to just vanish. If I put the line:
int x = int.Parse("XXX");
in (which generates an exception, obviously) then the code that's
executing just vanishes, leaving me back at the form (which carries on
working). If I deliberately catch an error, I catch it just fine.

Stepping through it line by line, it runs to the exception generating
line, and then just doesn't execute anything beyond that line.

I've checked my Exceptions dialog, and CLR Exceptions are definitely
set to Break Into Debugger if Not Handled.

Any idea why unhandled errors might not do anything at all?
Andy D

Nov 17 '05 #1
7 1565
I have seen cases (however I am never able to adequately reproduce them on
smaller scale) where when an exception occurs in a sub thread of my main app,
the thread just terminates. No CLR exception notice, just a note that the
thread has exited.

Where is the exception causing code occurring? Is it in your main thread or
something lower?

Brendan
"Andrew Ducker" wrote:
My unhandled exceptions seem to just vanish. If I put the line:
int x = int.Parse("XXX");
in (which generates an exception, obviously) then the code that's
executing just vanishes, leaving me back at the form (which carries on
working). If I deliberately catch an error, I catch it just fine.

Stepping through it line by line, it runs to the exception generating
line, and then just doesn't execute anything beyond that line.

I've checked my Exceptions dialog, and CLR Exceptions are definitely
set to Break Into Debugger if Not Handled.

Any idea why unhandled errors might not do anything at all?
Andy D

Nov 17 '05 #2
Hi,

There are couple of things to check, first are you doing that in a thread?
if so the UI will not receive it, you use AppDomain.UnhandledException or
Application.ThreadException

Also, check if you have your solution in debug mode, also check the project
properties to make sure you have optimization disabled.

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Andrew Ducker" <an****@ducker.org.uk> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
My unhandled exceptions seem to just vanish. If I put the line:
int x = int.Parse("XXX");
in (which generates an exception, obviously) then the code that's
executing just vanishes, leaving me back at the form (which carries on
working). If I deliberately catch an error, I catch it just fine.

Stepping through it line by line, it runs to the exception generating
line, and then just doesn't execute anything beyond that line.

I've checked my Exceptions dialog, and CLR Exceptions are definitely
set to Break Into Debugger if Not Handled.

Any idea why unhandled errors might not do anything at all?
Andy D

Nov 17 '05 #3
The calling regimen for WinForms works differently when running under
the debugger versus running independently. When _not_ running under the
debugger, in many instances your methods are called directly by Windows
rather than from where you think they should be called.

This can result in some strange run-time behaviour where exceptions are
concerned: some exceptions that are successfully caught by a
try...catch under the debugger take your app down outside the debugger.
If you look at the call stack you won't see the method that contains
the try...catch anywhere on the stack. Instead, you'll see your failing
code being called directly by Windows.

Another case is some exceptions that are trapped by a try...catch when
running under the debugger are caught instead by some generic
exception-handling code in a standard Windows form when running outside
the debugger. The form is designed to simply swallow exceptions and
keep running, which it does. (I use the PrintPreviewDialog, which does
this.)

Someone here once described in detail exactly how this works, but I
can't find the thread right now.

Nov 17 '05 #4
If you are in a thread, you can use ThreadException or add try catch in your
thread and when an exception is caught, use Application.OnThreadException(e)
to trasmit it to the main thread.

Is it whith drag/drop operations ? I already had the same problem in the
main thread with drag/drop operation. When you use DragOver or DragDrop
event, windows surround your code with try catch. And if one exception
occurs, it doesn't transmit it.

Hope it helps,
Ludovic Soeur.
"Andrew Ducker" <an****@ducker.org.uk> a écrit dans le message de
news:11**********************@z14g2000cwz.googlegr oups.com...
My unhandled exceptions seem to just vanish. If I put the line:
int x = int.Parse("XXX");
in (which generates an exception, obviously) then the code that's
executing just vanishes, leaving me back at the form (which carries on
working). If I deliberately catch an error, I catch it just fine.

Stepping through it line by line, it runs to the exception generating
line, and then just doesn't execute anything beyond that line.

I've checked my Exceptions dialog, and CLR Exceptions are definitely
set to Break Into Debugger if Not Handled.

Any idea why unhandled errors might not do anything at all?
Andy D

Nov 17 '05 #5
It's in my main thread - but it only happens once the message pump
starts - i.e. if I call code as part of the initialisation of the main
code, exceptions are detected, but if the same code is called from a
button press then the exception just evaporates.

Andy D

Nov 17 '05 #6
I've had a look, but can't find details. As I replied above:

"It's in my main thread - but it only happens once the message pump
starts - i.e. if I call code as part of the initialisation of the main
code, exceptions are detected, but if the same code is called from a
button press then the exception just evaporates."

Which makes it, indeed, sound like it's vanishing into the cracks in
Windows. I might just trap AppDomain.UnhandledException and see what
happens...

Cheers!

Andy D

Nov 17 '05 #7
Darnit - should have held off on posting. I added the following to the
start of my code:

AppDomain currentDomain = AppDomain.CurrentDomain;
currentDomain.UnhandledException +=new
UnhandledExceptionEventHandler(currentDomain_Unhan dledException);
Application.ThreadException +=new
System.Threading.ThreadExceptionEventHandler(Appli cation_ThreadException);

and then put some Messageboxes into those methods. Neither of them
ever get called. Something wierd is definitely going on.

Andy D

Nov 17 '05 #8

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

Similar topics

16
by: David Turner | last post by:
Hi all I noticed something interesting while testing some RAII concepts ported from C++ in Python. I haven't managed to find any information about it on the web, hence this post. The problem...
21
by: dkcpub | last post by:
I'm very new to Python, but I couldn't find anything in the docs or faq about this. And I fished around in the IDLE menus but didn't see anything. Is there a tool that can determine all the...
2
by: Greg | last post by:
There is a repeating issue of controls vanishing from a form in the Dev environment which is starting to get annoying. What happens is that I will have a form open in the IDE. The form will have...
0
by: Michael | last post by:
After trying to load my java applet from <OBJECT> tag (rather than <APPLET> tag), it renders fine, except when you click between the DESIGN view then back to HTML view, the <PARAM NAME="ARCHIVE"...
2
by: Linda | last post by:
Greetings, I am experiencing a problem similar to that mentioned in <a...
1
by: Anonieko | last post by:
Understanding and Using Exceptions (this is a really long post...only read it if you (a) don't know what try/catch is OR (b) actually write catch(Exception ex) or catch{ }) The first thing I...
2
by: mark4asp | last post by:
The first intem in a DropDownList is vanishing! My code to load a DropDownList is shown below. Yet when I load the page after a postback there is no zeroth item present. ...
0
RedSon
by: RedSon | last post by:
Chapter 3: What are the most common Exceptions and what do they mean? As we saw in the last chapter, there isn't only the standard Exception, but you also get special exceptions like...
36
by: TC | last post by:
I've used Access for many years. Several times, I've encountered a bug which I refer to as the "Vanishing Joins" bug. When it happens, joins vanish randomly from queries. More specifically, all...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...

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.