How to get calling method stack trace 
Author Message
 How to get calling method stack trace

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



Tue, 14 Dec 2004 10:14:37 GMT  
 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



Tue, 14 Dec 2004 21:42:59 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Getting the stack trace..

2. Getting the stack trace

3. Getting a stack trace

4. getting a stack trace after a segv (unix)

5. getting stack trace from inside program?

6. The C stack (or: implementing a stack trace)

7. Stack error calling a method of a TreeView interface

8. Getting the call stack at run-time

9. Getting error message while calling a method of the ATL object from ASP

10. IPersistStream* methods not getting called in IE DeskBand

11. Dialog methods not getting called.

12. Stack Trace Exception and Assert

 

 
Powered by phpBB® Forum Software