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)
Initializes a new instance of theclass with a specified exception.
The managed exception object that corresponds to the exception thrown in managed code.
Determines whether the specified object is equal to the current object.(Inherited from Object.)
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)
Serves as the default hash function. (Inherited from Object.)
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.
Available since 4.0
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.