Free mag vol1 | Page 318

CHAPTER 7  UNDERSTANDING STRUCTURED EXCEPTION HANDLING // Methods public virtual Exception GetBaseException(); public virtual void GetObjectData(SerializationInfo info, StreamingContext context); // Properties public virtual IDictionary Data { get; } public virtual string HelpLink { get; set; } public Exception InnerException { get; } public virtual string Message { get; } public virtual string Source { get; set; } public virtual string StackTrace { get; } public MethodBase TargetSite { get; } ... } As you can see, many of the properties defined by System.Exception are read-only in nature. This is due to the fact that derived types will typically supply default values for each property. For example, the default message of the IndexOutOfRangeException type is “Index was outside the bounds of the array.”  Note The Exception class implements two .NET interfaces. Although we have yet to examine interfaces (see Chapter 8), just understand that the _Exception interface allows a .NET exception to be processed by an unmanaged code base (such as a COM application), while the ISerializable interface allows an exception object to be persisted across boundaries (such as a machine boundary). Table 7-1 describes the most important members of System.Exception. Table 7-1. Core Members of the System.Exception Type 256 System.Exception Property Meaning in Life Data This read-only property retrieves a collection of key/value pairs (represented by an object implementing IDictionary) that provide additional, programmer-defined information about the exception. By default, this collection is empty. HelpLink This property gets or sets a URL to a help file or web site describing the error in full detail. InnerException This read-only property can be used to obtain information about the previous exception(s) that caused the current exception to occur. The previous exception(s) are recorded by passing them into the constructor of the most current exception.