Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6109999
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:28:01+00:00 2026-05-23T14:28:01+00:00

Lets say I have 3 classes: class A { void do_A() { //Check object

  • 0

Lets say I have 3 classes:

class A {
   void do_A() {
      //Check object call hierarchy
    }
}
class B {
   void do_B() {
      A a;
      a.do_A();
    }
}
class C {
   void do_C() {
      B b;
      b.do_A();
    }
}

And then I call:

C c;
c.do_C();

How can i get the object call hierarchy from within A’s do_A() ?

I mean I want to get the references of object in a.do_A() (can be easily attained by this), the reference of object b that called a.do_A(), and the reference of object c that called b.do_B().

I think this should be possible, because I can get the call hierarchy with call stack, so I’m sure I should be able to get some more information about the objects who called the methods.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T14:28:01+00:00Added an answer on May 23, 2026 at 2:28 pm

    I mean I want to get the references of
    object in a.do_A() (can be easily
    attained by this), the reference of
    object b that called a.do_A(), and the
    reference of object c that called
    b.do_B().

    I think this should be possible,
    because I can get the call hierarchy
    with call stack, so I’m sure I should
    be able to get some more information
    about the objects who called the
    methods.

    In general, what you ask for is not possible in .NET – even in theory. Perhaps unintuitively, there’s no guarantee that an object is still alive even when an instance-method on that object is in the midst of execution. Essentially, the CLR is smart enough to recognize when the hidden this reference passed to an instance-method will no longer be dereferenced. The referenced object can then become eligible for collection when this happens (assuming it is not reachable through other roots, of course).

    As a corollary, it’s also perfectly possible for a “calling object” to be dead while the method it has called is still executing. In your specific example, it’s perfectly possible that b and c (really the objects referred to by those variables) don’t exist anymore while A.do_A() is executing.

    What this means of course is that the information you seek may no longer be available in any form in the process, and no “magic” API should be able to reliably produce it.

    I recommend reading Raymond Chen’s article: When does an object become available for garbage collection? to understand this issue better:

    An object can become eligible for
    collection during execution of a
    method on that very object.

    If you feel this doesn’t relate to your question, consider the second-last paragraph in that article:

    Another customer asked, “Is there a
    way to get a reference to the instance
    being called for each frame in the
    stack? (Static methods excepted, of
    course.)” A different customer asked
    roughly the same question, but in a
    different context: “I want my method
    to walk up the stack, and if its
    caller is OtherClass.Foo, I want to
    get the this object for OtherClass.Foo
    so I can query additional properties
    from it.” You now know enough to
    answer these questions yourself.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets say i have the following c# classes: abstract class a { protected abstract
Let's say we already have a hierarchy of classes, e.g. class Shape { virtual
Lets say I have these classes: class Foo { public $_data; public function addObject($obj)
Let's say I have these classes : Vehicle, Car and Spaceship: class Vehicle{ void
Lets say we have this really trivial classes: class A { virtual int Function(int
Let's say i have 2 classes: class Class1 { public: std::vector<CustomClass3*> mVec; public: Class1();
Let's say we have these two classes: public class Base { public static int
Let's say I have some classes like this: abstract class View(val writer: XMLStreamWriter) {
Let's say I have a Base class and several Derived classes. Is there any
Let's say I have two models, Classes and People. A Class might have one

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.