S
Sherif ElMetainy
Hello
Using the System.Diagnostics.StackTrace class (see code below), I can know
that method that called my currently executing method. Is there a way I can
get a reference to the object instance used to call the method, i.e. the
this pointer for the calling method? I searched the FCL documentation for
such a method, but I didn't find any. Do I have to use Unmanaged code?
public class C2 {
public static void M1()
{
// here I can get the method that called my method
MethodInfo callingMethod = new StackTrace().GetFrame(1).GetMethod();
object callingObject; // I need to know how can I get a reference to
the calling object.
}
}
Note: My application will run using full trust, and normal user (not
Administrator) privileges.
Best regards,
Sherif
Using the System.Diagnostics.StackTrace class (see code below), I can know
that method that called my currently executing method. Is there a way I can
get a reference to the object instance used to call the method, i.e. the
this pointer for the calling method? I searched the FCL documentation for
such a method, but I didn't find any. Do I have to use Unmanaged code?
public class C2 {
public static void M1()
{
// here I can get the method that called my method
MethodInfo callingMethod = new StackTrace().GetFrame(1).GetMethod();
object callingObject; // I need to know how can I get a reference to
the calling object.
}
}
Note: My application will run using full trust, and normal user (not
Administrator) privileges.
Best regards,
Sherif