ExceptionHandlingClauseOptions Enumeration

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

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)

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

Member nameDescription
Clause

The clause accepts all exceptions that derive from a specified type.

Fault

The clause is executed if an exception occurs, but not on completion of normal control flow.

Filter

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.

Finally

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.

System_CAPS_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.

System_CAPS_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.
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.

.NET Framework
Available since 2.0
Return to top
Show: