Full Call Stack of the current Call Sequence

By Akbar

When debugging some problem, usually the “Call Stack” window is really of help. It let’s quickly see how you reached in current location i.e. call chain. This is of help when using some Visual Debugger, but you know what, the actual error happens when the application goes Live. For live applications, a good practice is to always log these errors in some database (or file) for latter analysis.

In .Net, during the runtime exception logging, most of us will use the Exception.StackTrace property to log the current stack trace. During analysis of different run-time errors, I found that some time the Exception.StrackTrace doesn’t return the full call chain. I think this is related to the classes which override the StackTrace property for content or format control.

Anyway, the good thing is that you can get full call chain, including the system calls, using the Environment.StackTrace. Though it’s large, but what it has is worth the bytes it consumes. Another advantage of the Environment.StackTrace property it works even when no exception has occurred.

Tags: , , ,