Solved

Method call stack

Posted on 2007-11-14
2
639 Views
Last Modified: 2011-10-03
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
Comment
Question by:andremara
2 Comments
 
LVL 22

Accepted Solution

by:
RedKelvin earned 500 total points
ID: 20284862
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
 

Author Comment

by:andremara
ID: 20285038
Very cool about StackTrace. Works like a champ.  Thanks.
Maybe I'll put the locals question separately - you got points!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question