Provides data for the notification event that is raised when a managed exception first occurs, before the common language runtime begins searching for event handlers.
Assembly: mscorlib (in mscorlib.dll)
Thetype exposes the following members.
|Equals(Object)||Determines whether the specified object is equal to the current object. (Inherited from Object.)|
|Finalize||Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)|
|GetHashCode||Serves as the default hash function. (Inherited from Object.)|
|GetType||Gets the Type of the current instance. (Inherited from Object.)|
|MemberwiseClone||Creates a shallow copy of the current Object. (Inherited from Object.)|
|ToString||Returns a string that represents the current object. (Inherited from Object.)|
This class provides the exception handler for the AppDomain::FirstChanceException event with access to the exception.
The following example creates a series of application domains named Child_0 through Child_3, with a Worker object in each application domain. Each Worker object has a reference to the Worker object in the next application domain, except for the Worker in the last application domain. The FirstChanceException event is handled in all application domains except Child_1.
When the application domains have been created, the default application domain calls the TestException method for the first child application domain. Each Worker object calls the TestException method for the next, until the last Worker throws an exception that is either handled or unhandled. Thus, the current thread passes through all the application domains, and TestException is added to the stack in each application domain.
When the last Worker object handles the exception, the FirstChanceException event is raised only in the last application domain. The other application domains never get a chance to handle the exception, so the event is not raised.
When the last Worker object does not handle the exception, the FirstChanceException event is raised in each application domain that has an event handler. After each event handler has finished, the stack continues to unwind until the exception is caught by the default application domain.
To see how the stack display grows as the event is raised closer and closer to the default application domain, change e.Exception.Message to e.Exception in the FirstChanceHandler event handlers. Notice that when TestException is called across application domain boundaries, it appears twice: once for the proxy and once for the stub.
Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.