By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,033 Members | 1,380 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,033 IT Pros & Developers. It's quick & easy.

Get Calling Method

P: n/a
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.WriteLine(trace.GetFrame(1).GetMethod.Name )

'// writes out "CallingMethod" to the console window
End Sub

I know my way around the System.Reflection 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,

May 5 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.