Expand Minimize

ExceptionHandlingClauseOptions Enumeration

Identifies kinds of exception-handling clauses.

This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values.

Namespace:  System.Reflection
Assembly:  mscorlib (in mscorlib.dll)

[<ComVisibleAttribute(true)>]
[<FlagsAttribute>]
type ExceptionHandlingClauseOptions

Member nameDescription
ClauseThe clause accepts all exceptions that derive from a specified type.
FaultThe clause is executed if an exception occurs, but not on completion of normal control flow.
FilterThe 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.
FinallyThe 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.

NoteNote

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.

NoteNote

Not all computer languages can generate ExceptionHandlingClauseOptions.Filter 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.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

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.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft