getting the name of the calling method
Posted
by zeocrash
on Stack Overflow
See other posts from Stack Overflow
or by zeocrash
Published on 2009-09-14T11:29:31Z
Indexed on
2010/03/31
22:13 UTC
Read the original article
Hit count: 378
vb.net
|reflection
Basically i've got a web service that i'm trying to put some kind of usage logging in. To do this i've created a class with a logging method. I instatiate the class on the service and then call the logging method in each of the web methods.
I'm trying to find a way of getting the name of the method that has called the loggong method
Public sub tstmethod
log_object.log_method
end sub
in this case the returned name i'm looking for is "tstmethod"
Everywhere i've seen has said to either use
Dim stackframe As New Diagnostics.StackFrame
Return stackframe.GetMethod.Name.ToString
Or to use
Dim stackframe As New Diagnostics.StackFrame
Return stackframe.GetMethod.DeclaringType.FullName
which i call inside the logging method
getmethod.name.tostring returns the name of the logging method
getmethod.declaringtype.fullname returns the name of the logging class
no matter what i do i cannot find a way of getting the name of the method that called the logging method in this case "tstmethod"
© Stack Overflow or respective owner