The FirstChanceException event of the AppDomain interface lets you receive a notification that an exception has been thrown, before the common language runtime has begun searching for exception handlers. The event is raised at the application domain level. A thread of execution can pass through multiple application domains, so an exception that is unhandled in one application domain could be handled in another application domain. The notification occurs in each application domain that has added a handler for the event, until an application domain handles the exception. The procedures and examples in this article show how to receive first-chance exception notifications in a simple program that has one application domain, and in an application domain that you create.
To demonstrate first-chance exception notifications in the default application domain
If your program contains more than one application domain, you can choose which application domains receive notifications.
Create an application domain and add the event handler to the FirstChanceException event for that application domain. In this example, the application domain is named AD1.