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());
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top