|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Determine caller class nameHi!
Is there a way in VB.NET to determine the caller's class name? System.Reflection.MethodBase.GetCurrentMethod.GetType basically telling me what is my current executing class, but I wanted to know, which caller class invoke my existing class method. Any help is much appreciated. Bob qing***@gmail.com wrote:
> Is there a way in VB.NET to determine the caller's class name? \\\Dim stack As New StackTrace Dim className As String className = stack.GetFrame(1).GetMethod.DeclaringType.Name /// The StackTrace object will contain details about the current call stack. The first element in the collection (element zero) will be your own current method, elements with higher indices will be the methods further up the call-stack. As the code that calls you will always be the second element on the call stack, you can access it using stack.GetFrame(1). HTH, -- (O)enone Thanks a lot. It definitely helps.
Oenone wrote: Show quoteHide quote > qing***@gmail.com wrote: > > Is there a way in VB.NET to determine the caller's class name? > > \\\ > Dim stack As New StackTrace > Dim className As String > > className = stack.GetFrame(1).GetMethod.DeclaringType.Name > /// > > The StackTrace object will contain details about the current call stack. The > first element in the collection (element zero) will be your own current > method, elements with higher indices will be the methods further up the > call-stack. As the code that calls you will always be the second element on > the call stack, you can access it using stack.GetFrame(1). > > HTH, > > -- > > (O)enone
Why choose SQL Express over Access?
Anyway To Compress PDF from .NET? Seeking report component.... AxWebBrowser problems in VS2005 Visual Basic 6.0 X Visual Basic 2005 Express VB.NET & SQL Server Connection Example Saving changes to a database Setting the correct tabindex A couple of newbie questions How to test internet connection in VB.NET? |
|||||||||||||||||||||||