In addition to Solution 1:
First of all, one of basic things is to understand the role and operation of stack.
Now, when you talk about the "error", you probably mean that an exception was thrown. When you catch an exception, you can dump a stack at this point be reading the property
System.Exception.StackTrace
:
http://msdn.microsoft.com/en-us/library/system.exception.stacktrace.aspx[
^].
This is a very important feature which can help debugging, but this is also a very good tool when you need to ask a question somewhere like CodeProject Questions & Answers.
However, this information is presented just as a string. You walk the stack during run time and get most comprehensive information is you use the class
System.Diagnostics.StackTrace
. Please see:
http://msdn.microsoft.com/en-us/library/system.exception.stacktrace.aspx[
^].
Pay attention for the code sample in the MSDN article referenced above.
—SA