Know which Object Create the instance

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

Hi,
There are some way to know which object (A) create an instance of object (B)
in the constructor of object (B)?

Thanks.
 
Not to my knowledge but you can easily passe a reference of A to the
constructor of B.

S. L.
 
You can find out which TYPE called the object constructor, but I don't
know how to find out which object instance.

public MyConstructor()
{
System.Diagnostics.StackFrame frame = new
System.Diagnostics.StackFrame(1);
Type callerType = frame.GetMethod().DeclaringType;
}
 
Back
Top