Identifies kinds of exception-handling clauses.
This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values.
Assembly: mscorlib (in mscorlib.dll)
|The clause accepts all exceptions that derive from a specified type.|
|The clause is executed if an exception occurs, but not on completion of normal control flow.|
|The clause contains user-specified instructions that determine whether the exception should be ignored (that is, whether normal execution should resume), be handled by the associated handler, or be passed on to the next clause.|
|The clause is executed whenever the try block exits, whether through normal control flow or because of an unhandled exception.|
To examine the exception-handling clauses in a method, obtain a MethodInfo object and call the GetMethodBody method to obtain the method body. Use the ExceptionHandlingClauses property to obtain a list of ExceptionHandlingClause objects.
Working with exception-handling clauses requires a thorough understanding of metadata and Microsoft intermediate language (MSIL) instruction formats. Information can be found in the Common Language Infrastructure (CLI) documentation, especially "Partition II: Metadata Definition and Semantics" and "Partition III: CIL Instruction Set". The documentation is available online; see ECMA C# and Common Language Infrastructure Standards on MSDN and Standard ECMA-335 - Common Language Infrastructure (CLI) on the Ecma International Web site.
The following code example defines a test method named MethodBodyExample, and displays its local variable information and exception-handling clauses. The MethodBase.GetMethodBody method is used to obtain a MethodBody object for the test method. The ExceptionHandlingClauses property is used to obtain a list of ExceptionHandlingClause objects and display their properties.
Not all computer languages can generate clauses. The Visual Basic example shows a filter clause, using a Visual Basic When expression, which is omitted from the examples for other languages.
This code is part of a larger example provided for the MethodBody class.
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.