473,804 Members | 3,330 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Exception not catched in right place

Hello,

I have situation similar like this.

class Class1{
private Class2 obj2;
...
public bool method1(Class3 ob3j, DateTime dt){
try{
obj2.Method2(ob j3, dt);
}
catch(Exception e) {
Console.WriteLi ne(e.ToString() )
}
}
}

class Class2{
public bool method2(Class3 obj3, DateTime dt){
try{
Console.WriteLi ne("Class2,meth od2");
...
}
catch{
return false;
}
return true;
}

When I call method1 from COM client. Sometimes I got excepion from
method2 but it not catched in method2. It will catched in method1 and
exception says that it happen in method2. Exception is "Arithmetic
operation resulted in an overflow".
What could be a reason that exception is not catched in method2?

Feb 24 '06 #1
4 1419

I haven't experienced this myself, but have you tried adding
catch(Exception ex) to method2?
BugSentry needs beta testers!
www.bugsentry.com

*** Sent via Developersdex http://www.developersdex.com ***
Feb 24 '06 #2
Yes I tried that too but no efect.
This weird behavior look me that framework is totaly mess.

Feb 26 '06 #3

<ko****@yahoo.c om> wrote in message
news:11******** **************@ p10g2000cwp.goo glegroups.com.. .
| Yes I tried that too but no efect.
| This weird behavior look me that framework is totaly mess.
|

Post a small but complete sample that illustrates the issue.

Willy.
Feb 27 '06 #4
I'm not familiar with what happens in the case of COM, but I know that
the way that exceptions work can sometimes be counterintuitiv e when
dealing with Windows Forms.

Remember that not all calls happen when you think they do. Of course, a
direct call like the one shown in the code sample will happen when you
expect it to, and the exceptions should work the way that you expect
them to, but I don't know what will happen when you venture into the
world of COM.

In WinForms, calls to event handlers (such as button press handlers)
are often queued on the event queue and then later called directly from
the WinForms base event loop (sorry for murdering the terminology... :)
). So, what looks like a straightforward call to an event handler ends
up being queued and handled later, and so exceptions within that call
don't bubble back "up" to what appears to be the event origin, because
the event origin queued the event and then long ago exited, so you get
stack dumps that show your method being called directly from the
runtime, rather than from whence you thought it would be called.

That's a good question here: what does the stack dump on the exception
look like? Is the method being called from where you thought it was
being called?

Tens of thousands of programmers are using the .NET Framework to do all
sorts of things. While there may be a (few) bugs, and some of the
Framework's behaviour may not make sense until you investigate it
further, I have a hard time believing that our lack of understanding
makes the whole thing a writeoff, or a "mess" as you put it.

Feb 28 '06 #5

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

Similar topics

10
30329
by: Gary.Hu | last post by:
I was trying to catch the Arithmetic exception, unsuccessfully. try{ int a = 0, b = 9; b = b / a; }catch(...){ cout << "arithmetic exception was catched!" << endl; } After ran the program, it quitted with core dumped. %test
6
2140
by: Páll Ólafsson | last post by:
Hi I have a problem with the Microsoft.ApplicationBlocks.ExceptionManagement? I can't get it to work in RELEASE mode? If I run the project in debug mode the block works fine but when I run the exe file it doesn't catch any errors? Does anyone know what my problem might be? Regards
1
1314
by: Salvador Ponticelli | last post by:
In an ASP.NET Application I have an instance of a remoting object. After the instance was created, I saved it in a Session variable. When I try to use this instance with the Remoting Service down, it throw an exception wich it is catched. After this exception is catched, another exception is throwed outside my try-catch blocks. I can´t catch this new exception. This happen only in first and second execution after application compile. After...
16
6596
by: ChInKPoInt [No MCSD] | last post by:
I am using Visual Studio 2K3 writing a ASP.NET web application. Is there a way to force the C# compiler to catch possible exception? In Java, all exceptions thrown MUST BE caught, otherwise compiler would give you error. In C#, is there a way to do that?
2
5875
by: Rajeev Soni | last post by:
Hi, Considering the scenario for handling exceptions in Web Application where we have Presentation layer, Business layer and Data Access layer; if there any exception is occurred in DAL, what is the best thing to do: 1. Dont catch the exception in DAL and let it prop up to the Application level and the Global.Application_Error event log it to any source and show let ASP.NET show custom error page provided in Web.Config file. OR 2....
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,...
4
1209
by: Paul Czubilinski | last post by:
Hello, I have code like this: class MyException extends Exception {} function x() { try { throw new MyException() } catch (Exception $e) {
6
3394
by: Mohan | last post by:
Hi, I am learning the Exception Handling in C++. I wrote a small program using Exception Handling. I am using Vistual Studio 6. It is working fine in Win32 Debug build, but it is not catching the exception in Win32Release mode.
4
1511
by: michael | last post by:
Hello everybody, I've created for one of my classes a exception class derivated from System.Exception. This exception class is public and lies within my class as inner class. When I throw this exception I can't catch it with its name! When I try to catch it with it's name then the catch-block will be ignored.... So I've made a general catch with System.Exception and printed the runtime type...
0
9706
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
10571
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
10326
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
10317
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
10075
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...
0
9143
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7615
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
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3815
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.