User Tools

Site Tools


development:net:who_called

Find out who called a .NET method

When debugging, it is useful to know who called a method (if it is being called from multiple places)

Include these

Imports System.Reflection
Imports System.Diagnostics

Place this code on the beginning of the method being called.

Dim st As StackTrace = New StackTrace()
Dim sf As StackFrame = st.GetFrame(1)
MsgBox("I was called by: " & sf.GetMethod.Name)
development/net/who_called.txt · Last modified: 2017/11/23 10:49 by tplecko