Visual Studio .NET 2003
The order of events for a thrown exception is as follows:
- The runtime walks the stack looking for the appropriate
catchclause, or in the case of SEH, an
exceptfilter for SEH, to catch the exception. Catch clauses are searched first in lexical order, and then dynamically down the call stack.
- Once the correct handler is found, the stack is unwound to that point. For each function call on the stack, its local objects are destructed and
__finallyblocks are executed, from most nested outward.
- Once the stack is unwound, the
catchclause is executed.