Export (0) Print
Expand All
Expand Minimize

OpCodes.Endfinally Field

Transfers control from the fault or finally clause of an exception block back to the Common Language Infrastructure (CLI) exception handler.

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

public static readonly OpCode Endfinally
public static final OpCode Endfinally
public static final var Endfinally : OpCode
Not applicable.

The following table lists the instruction's hexadecimal and Microsoft Intermediate Language (MSIL) assembly format, along with a brief reference summary:

Format

Assembly Format

Description

DC

endfinally

endfault

Ends the finally or fault clause of an exception block.

There are no stack transition behaviors for this instruction.

Endfinally and endfault signal the end of the finally or fault clause so that stack unwinding can continue until the exception handler is invoked. The endfinally or endfault instruction transfers control back to the CLI exception mechanism. The mechanism then searches for the next finally clause in the chain if the protected block was exited with a leave instruction. If the protected block was exited with an exception, the CLI will search for the next finally or fault, or enter the exception handler chosen during the first pass of exception handling.

An endfinally instruction might only appear lexically within a finally block. Unlike the endfilter instruction, there is no requirement that the block end with an endfinally instruction, and there can be as many endfinally instructions within the block as required. These same restrictions apply to the endfault instruction and the fault block.

Control cannot be transferred into a finally (or fault) block except through the exception mechanism. Control cannot be transferred out of a finally (or fault) block except through the use of a throw instruction or executing the endfinally (or endfault) instruction. In particular, you cannot "fall out" of a finally (or fault) block or to execute a Ret or Leave instruction within a finally (or fault) block.

Note that the endfault and endfinally instructions are aliases - they correspond to the same opcode.

The following Emit method overload can use the endfinally (endfault) opcode, as well as the ILGenerator method EndExceptionBlock.

  • ILGenerator.Emit(OpCode)

  • ILGenerator.EndExceptionBlock()

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft