Solved

Method call stack

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Converting Newtonsoft.Json.Linq.JToken to a DateTime 4 73
cs.Designer Issue 2 20
Long URL in SMS 6 24
Achieve json result 2 35
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!
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This video discusses moving either the default database or any database to a new volume.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

744 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

10 Experts available now in Live!

Get 1:1 Help Now