473,799 Members | 2,666 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 RegisterWindowM essage 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.OnT hreadException 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 1199
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::Excepti on
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.con fig 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" ?>
<configuratio n>
<system.windows .forms jitDebugging="t rue" />
</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::Excepti on
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::Excepti on
{
public:
/*
Constructors, private methods, and other stuff.

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



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.con fig 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.window s.forms jitDebugging="t rue" />
</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.confi g?

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
5005
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 following code exhibits the bug. If it is built and run from Visual Studio.NET 2003 in debug mode it works correctly as expected. However, if built in Release mode it fails with an "uncaught exception" error, although the exception does have a valid...
44
4233
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 user tasks should always be included in a try/catch block that actually handles any exceptions that occur (log the exception, display a message box, etc.). 2. Low-level operations that are used to carry out the high level tasks
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 ( +7) / 227 closed ( +7) / 451 total (+14) New / Reopened Patches ______________________
0
11461
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 (-15) / 266 closed (+13) / 523 total ( -2) New / Reopened Patches ______________________
0
9689
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
10269
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...
1
10248
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10032
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
7573
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
5469
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
5597
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2942
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.