Home All Groups Group Topic Archive Search About

Full qual. name of current method

Author
17 Oct 2006 12:26 PM
pamelafluente
Hi guys,

  How do I get the full name of the current (overload) function or sub
(whatever it be) ?

  Sub SomeFunction()

      Dim FullNameOfThisFunction = ???
      msgbox(FullNameOfThisFunction )

end sub

-P

Author
17 Oct 2006 1:12 PM
Phill W.
pamelaflue***@libero.it wrote:

>   How do I get the full name of the current (overload) function or sub
> (whatever it be) ?

Imports System.Reflection

Dim mb as MethodBase _
    = MethodBase.GetCurrentMethod()

? mb. ...

HTH,
    Phill  W.
Author
17 Oct 2006 2:08 PM
pamelafluente
Phill W. ha scritto:
>
> Dim mb as MethodBase _
>     = MethodBase.GetCurrentMethod()
>

Thanks Phill . Very helpful.
I would also need the name of the caller. Is it simple to get ?

Sub Caller
              me.CalledBy()
end sub

  Sub CalledBy()
              Dim FullNameOfCallerSub  = ?????
              msgbox(FullNameOfCallerSub)
  end sub
Author
18 Oct 2006 1:19 PM
Jay B. Harlow
Pamela,
> I would also need the name of the caller. Is it simple to get ?
You can use the System.Diagnostics.StackTrace &
System.Diagnostics.StackFrame classes.

        Dim trace As New StackTrace()
        Dim caller As StackFrame = trace.GetFrame(1)
        Debug.WriteLine(caller.GetMethod(), "caller")


--
Hope this helps
Jay B. Harlow
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net


<pamelaflue***@libero.it> wrote in message
Show quoteHide quote
news:1161094126.501697.121150@b28g2000cwb.googlegroups.com...
>
> Phill W. ha scritto:
>>
>> Dim mb as MethodBase _
>>     = MethodBase.GetCurrentMethod()
>>
>
> Thanks Phill . Very helpful.
> I would also need the name of the caller. Is it simple to get ?
>
> Sub Caller
>              me.CalledBy()
> end sub
>
>  Sub CalledBy()
>              Dim FullNameOfCallerSub  = ?????
>              msgbox(FullNameOfCallerSub)
>  end sub
>
Author
19 Oct 2006 4:52 PM
pamelafluente
Jay B. Harlow ha scritto:

> Pamela,
> > I would also need the name of the caller. Is it simple to get ?
> You can use the System.Diagnostics.StackTrace &
> System.Diagnostics.StackFrame classes.
>
>         Dim trace As New StackTrace()
>         Dim caller As StackFrame = trace.GetFrame(1)
>         Debug.WriteLine(caller.GetMethod(), "caller")
>
>
> --
> Hope this helps

Thanks very helpful.



Thanks to all.

Show quoteHide quote
> Jay B. Harlow
> .NET Application Architect, Enthusiast, & Evangelist
> T.S. Bradley - http://www.tsbradley.net
>
>
> <pamelaflue***@libero.it> wrote in message
> news:1161094126.501697.121150@b28g2000cwb.googlegroups.com...
> >
> > Phill W. ha scritto:
> >>
> >> Dim mb as MethodBase _
> >>     = MethodBase.GetCurrentMethod()
> >>
> >
> > Thanks Phill . Very helpful.
> > I would also need the name of the caller. Is it simple to get ?
> >
> > Sub Caller
> >              me.CalledBy()
> > end sub
> >
> >  Sub CalledBy()
> >              Dim FullNameOfCallerSub  = ?????
> >              msgbox(FullNameOfCallerSub)
> >  end sub
> >
Author
17 Oct 2006 3:20 PM
Herfried K. Wagner [MVP]
<pamelaflue***@libero.it> schrieb:
>  How do I get the full name of the current (overload) function or sub
> (whatever it be) ?
>
>  Sub SomeFunction()
>
>      Dim FullNameOfThisFunction = ???
>      msgbox(FullNameOfThisFunction )

'MethodBase.GetCurrentMethod().Name'

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>