Click to See Complete Forum and Search --> : Reflection, Get Calling Method/Class Info [Resolved]
<ABX
Jul 26th, 2004, 01:16 AM
Is it possible to get the Name and Class of a method that calls a method.
'This works for getting information about the calling assembly, but not anything more indepth.
MsgBox("I was Called by: " & Reflection.Assembly.GetCallingAssembly.GetName.Name)
skybound.ca
Jul 26th, 2004, 06:11 AM
Try this:
Dim method As System.Reflection.MethodBase
' the calling method is always frame 1 of the call stack (the current method is frame 0):
method = New System.Diagnostics.StackTrace().GetFrame(1).GetMethod()
' show the name of the calling method:
MessageBox.Show(method.Name)
You can then use member.ReflectedType to get information about the class.
No guarantees on performance here.
<ABX
Jul 26th, 2004, 06:28 AM
Thanks :D
Im not too worried about speed issue because this is for a debugging feature that will only be on when developing and testing.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.