Alex Rivera | Logout

Programmatically get C# Stack Trace

Asked 2011-07-08T12:22:03.443
48

Possible Duplicate:
How to print the current Stack Trace in .NET without any exception?

When an exception is thrown, its text contains the stack trace. Can I somehow obtain the stack trace text(including file and line) without exceptions?

public void f()
{
   //blah
   string stacktrace = ???;
   //blah
}
Edit
Report

1 Answer

15
string stackTrace = Environment.StackTrace;
answered 2011-07-08T12:24:41.383

Your Answer