Eric Haskins
Eric Haskins

Reputation: 8605

Programatic access to call stack in .net

How can I get programmatic access to the call stack?

Upvotes: 12

Views: 3042

Answers (3)

Scott Dorman
Scott Dorman

Reputation: 42516

The right way is to use the StackTrace and StackFrame classes. Throwing an exception just to get the stack trace is completely misusing exceptions.

Upvotes: 1

James Avery
James Avery

Reputation: 3012

You can use the StackTrace and StrackFrame classes in System.Diagnostics.

Upvotes: 6

Matt Hamilton
Matt Hamilton

Reputation: 204239

Try System.Diagnostics.StackTrace.

Upvotes: 22

Related Questions