How to get calling method stack trace
Simon,
You can use the StackTrace class, passing in 1 to the constructor,
meaning that you would skip the first frame (the current stack). You can
pass higher numbers, meaning you should start the trace further up in the
stacks.
Hope this helps.
--
- Nicholas Paldino [.NET MVP]
Quote:
> How can i get a stack trace of a calling method without an exception?
> i want to basically do
> 'System.Reflection.MethodBase.GetCurrentMethod().GetCallingMethod();'
> but theres no such method.
> basically i have a logging class and i want to log not only the exception,
> but
> also what actually issued the Log(....) command.
> -simon