As I mentioned earlier, the
System.Exception type offers a public, read-only
StackTrace property. An exception filter or a
catch block can read this property to obtain the stack trace indicating what events occurred up to the exception. This information can be extremely valuable when you’re trying to detect the cause of an exception so that you can correct your code. In this section, I’ll discuss some issues related to the stack trace that aren’t immediately obvious.
StackTrace property is magical. When you access this property, you’re actually calling into code in the CLR; the property doesn’t simply return a string. When you construct a new object of an
Exception-derived type, the
StackTrace property ...