[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 654
  • Last Modified:

Method call stack

Could I have a code snippet to obtain the method call stack, maybe in an array, for debugging purposes.
I intend to dump the stack when an error is intercepted.
So,
If Main, calls Method1, which calls Method2,
I'd like to have some kind of structure which holds:
Method2
Method1
Main
as its contents.

I'd be extra happy if I could also have some structure holding all current local variables.  Wow - that would be helpful as something to write out to an error log for inspection after failure.

Thanks!
Andre
0
andremara
Asked:
andremara
1 Solution
 
RedKelvinCommented:
Hi,
try using Environment.StackTrace

http://refact.blogspot.com/2007/01/get-current-stack-trace.html

As for the locals, I am thinking about it, but it is a tough one
0
 
andremaraAuthor Commented:
Very cool about StackTrace. Works like a champ.  Thanks.
Maybe I'll put the locals question separately - you got points!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now