Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically get C# Stack Trace [duplicate]

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 } 
like image 205
Armen Tsirunyan Avatar asked Jul 08 '11 12:07

Armen Tsirunyan


1 Answers

Environment.StackTrace or System.Diagnostics.StackTrace if you need a more convienient (i.e. not string) representation

like image 93
larsmoa Avatar answered Sep 19 '22 04:09

larsmoa