how to get the callstack description w/o exception

  • Thread starter Thread starter Zeng
  • Start date Start date
Z

Zeng

Hello,

In my code, when I run into an error, I would like to dump the callstack
into error log, how do I do that w/o throwing an exception then catching it
just to get the callstack? Exception structure has callstack information
but I thought there must be a way to directly retrieve it. Thanks!
 
Take a look at System.Diagnostics.StackTrace, simple example would be
something like:

System.Diagnostics.StackTrace stack = new System.Diagnostics.StackTrace();
Console.WriteLine(stack.ToString());
 
Back
Top