473,513 Members | 4,753 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do I find out what class called me

Art
Hi,

I want to write an error handler for my project. I would call this handler
and have it print a message. What I'd like to be able to do is to have the
handler know which class called it. Also, since the class that called it may
have been passed bad data from another class, I'd like to pass the name of
the other class also (if applicable).

So, suppose Class A instantiates Class B. Can Class B know who Class A is
without Class A passing that information as a parameter?

I'd appreciate any suggestions or advice.

Art
Nov 21 '05 #1
4 1387
Art schrieb:
Hi,

I want to write an error handler for my project. I would call this handler
and have it print a message. What I'd like to be able to do is to have the
handler know which class called it. Also, since the class that called it may
have been passed bad data from another class, I'd like to pass the name of
the other class also (if applicable).

So, suppose Class A instantiates Class B. Can Class B know who Class A is
without Class A passing that information as a parameter?

I'd appreciate any suggestions or advice.

Art

dim st as new stacktrace
Have a look at st.framecount and st.getframe and all the members of the
returned objects including the type information you get from them. See also
System.Reflection.MethodBase.GetCurrentMethod

Armin
Nov 21 '05 #2
Art schrieb:
Hi,

I want to write an error handler for my project. I would call this handler
and have it print a message. What I'd like to be able to do is to have the
handler know which class called it. Also, since the class that called it may
have been passed bad data from another class, I'd like to pass the name of
the other class also (if applicable).

So, suppose Class A instantiates Class B. Can Class B know who Class A is
without Class A passing that information as a parameter?

I'd appreciate any suggestions or advice.

Art

I should add: When throwing an exception, you already have a stacktrace.
Armin
Nov 21 '05 #3
> dim st as new stacktrace


Have a look at st.framecount and st.getframe and all the members of the
returned objects including the type information you get from them. See
also System.Reflection.MethodBase.GetCurrentMethod


Wow, that's pretty badass. I am deeply impressed. I would never have
thought of that!
--
Peace & happy computing,

Mike Labosh, MCSD

"Mr. McKittrick, after very careful consideration, I have
come to the conclusion that this new system SUCKS."
-- General Barringer, "War Games"
Nov 21 '05 #4
Art
Armin,

Thanks very much for the help. This is a whole new area for me so it's
going to take some time to figure it all out.

Art

"Armin Zingler" wrote:
Art schrieb:
Hi,

I want to write an error handler for my project. I would call this handler
and have it print a message. What I'd like to be able to do is to have the
handler know which class called it. Also, since the class that called it may
have been passed bad data from another class, I'd like to pass the name of
the other class also (if applicable).

So, suppose Class A instantiates Class B. Can Class B know who Class A is
without Class A passing that information as a parameter?

I'd appreciate any suggestions or advice.

Art

I should add: When throwing an exception, you already have a stacktrace.
Armin

Nov 21 '05 #5

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

Similar topics

1
3539
by: Saeed Amrollahi | last post by:
Dear All C++ Programmers Hello I am Saeed Amrollahi. I am a software engineer in Tehran Sewerage Company. I try to use std::map and map::find member function. I use Visual Studio .NET. my...
12
6706
by: Rubbrecht Philippe | last post by:
Hi there, According to documentation I read the ArrayList.IndexOf method uses the Object.Equals method to loop through the items in its list and locate the first index of an item that returns...
5
3001
by: Mike Labosh | last post by:
In VB 6, the Form_QueryUnload event had an UnloadMode parameter that let me find out *why* a form is unloading, and then conditionally cancel the event. In VB.NET, the Closing event passes a...
11
2120
by: localpricemaps | last post by:
i have some html which looks like this where i want to scrape out the href stuff (the www.cnn.com part) <div class="noFood">Cheese</div> <div class="food">Blue</div> <a class="btn" href =...
4
4728
by: KL | last post by:
Hello again, I am still working on this homework assignment and have hit a wall. I have a list that I want to fill with all occurences of img tags from a big string of html code. So I have a...
6
3614
by: roland.bali | last post by:
Hi, Here is the basic setup, my base class is Shoe which has a child class called Sandal. I would like to create objects by calling Sandal.Load. But without overloading Load in Sandal and...
7
1624
by: Nemisis | last post by:
Hi everyone, Can anyone tell me if it is possible to pass in a property of an object into a sub, and within that sub, find out the name of the item that was passed along with the property name??...
0
1034
by: =?Utf-8?B?Sm9l?= | last post by:
This may seem a little silly but please bear with me... I have a page called Page1.aspx and a code behind Page1.aspx.cs. In the code behind I declare a class called OdsDataSource as a CHILD...
18
3848
by: Neehar | last post by:
Hello For one of the interviews I took recently, I was given an offline programming quiz. In 30 minutes I had to write code in C++ to counts the number of times each unique word appears in a...
0
7254
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
7373
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
7432
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
7094
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...
1
5079
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
4743
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3218
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1585
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 ...
1
796
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.