This is what I am talking about:
Public Shared Sub Test1()
Test2()
End Sub
Public Shared Sub Test2()
MsgBox(Test2.LastMethod) ' Test1
End Sub
I would imagine if this is possible, System.Reflection
will be utilized?
Any thoughts?
This is what I am talking about:
Public Shared Sub Test1()
Test2()
End Sub
Public Shared Sub Test2()
MsgBox(Test2.LastMethod) ' Test1
End Sub
I would imagine if this is possible, System.Reflection
will be utilized?
Any thoughts?
Look at the System.Diagnostics.StackFrame class.
StackFrame frame = new StackFrame(1);
MethodBase method = frame.GetMethod();
Console.WriteLine(method.Name);
As a side note you shouldn't depend on who you caller is and shouldn't use this unless you are writing a debugger or for logging purposes.
Dim stackFrame As New Diagnostics.StackFrame(1)
stackFrame.GetMethod.Name.toString() & stackFrame.GetMethod.DeclaringType.FullName.tostring()
Should give you the full name.
This question should help:
http://stackoverflow.com/questions/44153/can-you-use-reflection-to-find-the-name-of-the-currently-executing-method
Be careful how you do this. If your method is JIT-inlined you might see the wrong method.