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: 2019/10/31 09:04
  • by 127.0.0.1