Solved

Method call stack

Posted on 2007-11-14
2
632 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

895 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now