473,513 Members | 2,409 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

BUG: An exception does not propagate correctly to the calling function in a Windows Forms applicatio

This thread is a continuation of a thread with the Subject "Unhandled
exception - Different under debugger and non-debugger".
(http://www.dotnetnewsgroups.com/news....asp?ID=186902)

Oleg and Carl:

Carl wrote: "I would think the only fully sanitary, guaranteed to work
way would be to either terminate the program from inside the handler, or
intern the exception in an object and pass (a pointer to) that object
through a WM_APP window message where your message loop can unwrap it
and re-throw or otherwise handle the exception."

I’m pretty good when it comes to MFC and WTL. I am just learning how to
use the .Net environment and, frankly, there is a whole new gestalt here
that I’m missing. I am clueless as to whether a message pump even exists
in this environment. I’m guessing that there probably is and it has
been buried deep so that mere mortals don’t have to mess with it.

So, Oleg, my question to you is, “Does what Carl suggests solve the
problem?” If it does, what’s the right way to do it?

Fleshing out Carl’s remark, I assume that the proper way to do what he
says is to do a RegisterWindowMessage to get a unique message number and
to post a message. My problem is that I am clueless as to how to code a
handler to process the message.
Another question to you, Oleg, is that the article you cited
(http://support.microsoft.com/default...b;en-us;836674) seems
to be talking about this in terms of SEH rather than C++ exceptions.

Another point of confusion that I have is that the article you cited
says “In Visual Studio .NET 2003, click Application Configuration File
under Template, and then click Open”. Well, I’m running 2003 and there
is no Application Configuration File under Template. There’s a resource
template icon but no “XML file” under it. Sigh.

I followed the procedure under 2002 (even though I’m running 2003). I
followed those instructions and, as far as I can tell, there are no
behavioral differences. Sigh.

I haven’t tried MS’s “Another workaround for this problem is to use the
Application.OnThreadException handler” because I don’t understand what
they’re trying to accomplish.
--
Sent via .NET Newsgroups
http://www.dotnetnewsgroups.com
Nov 17 '05 #1
2 1192
So, Oleg, my question to you is, "Does what Carl suggests solve the
problem?" If it does, what's the right way to do it?

Yes, it does, but only for native C++ exceptions, while your application
seems to use managed exceptions. Managed exceptions can be thrown/caught
across message pumps.

(In case of native exceptions, my solution would be to catch everything that
I know should be caught before it can potentially cross CRT boundaries
(that is, do not allow native C++ exceptions that are used by my code
to leave the message handlers). I would leave everything else to the default
just-in-time debugging mechanism).


Another question to you, Oleg, is that the article you cited
(http://support.microsoft.com/default...b;en-us;836674) seems
to be talking about this in terms of SEH rather than C++ exceptions.

It is talking about managed exceptions. It applies to System::Exception
and types derived from it. Btw, how is your exception class (MyException) defined?

Another point of confusion that I have is that the article you cited
says "In Visual Studio .NET 2003, click Application Configuration File
under Template, and then click Open". Well, I'm running 2003 and there
is no Application Configuration File under Template. There's a resource
template icon but no "XML file" under it. Sigh.


Create the file manually, name it yourapp.exe.config and place it into the same
directory with yourapp.exe (substitute the real name, of course :)
The file should contain the following:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>

This should change the behavior of your application when running without debugger
(your handler will be able to catch the exception).

Oleg


Nov 17 '05 #2
Oleg:

[snip]
It is talking about managed exceptions. It applies to System::Exception
and types derived from it. Btw, how is your exception class (MyException) defined?

/* MyException.h */

#pragma once

#using <mscorlib.dll>
public __gc
class MyException: public System::Exception
{
public:
/*
Constructors, private methods, and other stuff.

Oleg, do you need/want the full class?
*/
}; /* class MyException: System::Exception */



Another point of confusion that I have is that the article you cited
says "In Visual Studio .NET 2003, click Application Configuration File under Template, and then click Open". Well, I'm running 2003 and there is no Application Configuration File under Template. There's a resource template icon but no "XML file" under it. Sigh.


Create the file manually, name it yourapp.exe.config and place it into

the samedirectory with yourapp.exe (substitute the real name, of course :)
The file should contain the following:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>

This should change the behavior of your application when running without debugger(your handler will be able to catch the exception).
Thanks!

Is it my imagination, but does it take a very long time for the
executable to load the first time it is loaded when I put in
myApp.exe.config?

Oleg


Ralph

--
Sent via .NET Newsgroups
http://www.dotnetnewsgroups.com
Nov 17 '05 #3

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

Similar topics

9
4987
by: David B | last post by:
Why is it so difficult to report bugs to Microsoft? I have a documented bug and an small test example. I don't really see why I should have to pay to tell them about it... Anyway, the...
44
4162
by: craig | last post by:
I am wondering if there are some best practices for determining a strategy for using try/catch blocks within an application. My current thoughts are: 1. The code the initiates any high-level...
0
361
by: Kurt B. Kaiser | last post by:
Patch / Bug Summary ___________________ Patches : 378 open ( +3) / 3298 closed (+34) / 3676 total (+37) Bugs : 886 open (-24) / 5926 closed (+75) / 6812 total (+51) RFE : 224 open...
0
11225
by: Kurt B. Kaiser | last post by:
Patch / Bug Summary ___________________ Patches : 342 open (-38) / 3712 closed (+54) / 4054 total (+16) Bugs : 951 open (-14) / 6588 closed (+33) / 7539 total (+19) RFE : 257 open...
0
7267
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
7391
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
7553
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...
1
7120
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
7542
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
5697
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,...
1
5100
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...
0
3247
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...
1
809
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.