Hi all,
I have recently come up with a way to get the calling method of the
current method, and I just want to know if this is a sound way to go
about it:
Sub CallingMethod()
Call CalledMethod()
End Sub
Sub CalledMethod()
Dim trace As New StackTrace(True )
Console.WriteLi ne(trace.GetFra me(1).GetMethod .Name)
'// writes out "CallingMet hod" to the console window
End Sub
I know my way around the System.Reflecti on namespace well enough, but I
don't do it enough to know if there is going to be some kind of major
negative side effects of doing this. I realize that the calling method
may be one I don't expect (such as Invoke, or InvokeMethod), but other
than that, do you see any issues?
Thanks in advance,
Jeremy
I have recently come up with a way to get the calling method of the
current method, and I just want to know if this is a sound way to go
about it:
Sub CallingMethod()
Call CalledMethod()
End Sub
Sub CalledMethod()
Dim trace As New StackTrace(True )
Console.WriteLi ne(trace.GetFra me(1).GetMethod .Name)
'// writes out "CallingMet hod" to the console window
End Sub
I know my way around the System.Reflecti on namespace well enough, but I
don't do it enough to know if there is going to be some kind of major
negative side effects of doing this. I realize that the calling method
may be one I don't expect (such as Invoke, or InvokeMethod), but other
than that, do you see any issues?
Thanks in advance,
Jeremy