System.Reflection.Emit.OpCodes.Calli Field

Calls the method indicated on the evaluation stack (as a pointer to an entry point) with arguments described by a calling convention.

Syntax

public static readonly OpCode Calli

Remarks

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

29 < T >

calli callSiteDescr

Calls the method pointed to with arguments described by the calling convention.

The stack transitional behavior, in sequential order, is:

[The 'ordered' type of list has not been implemented in the ECMA stylesheet.]

The calli instruction calls the method entry pointer with the arguments arg1 through argN. The types of these arguments are described by the specific calling convention (callSiteDesc). The calli instruction may be immediately preceded by a tail prefix (OpCodes.Tailcall) to specify that the current method state should be released before transferring control. If the call would transfer control to a method of higher trust than the origin method the stack frame will not be released; instead, the execution will continue silently as if the tail had not been supplied.

The method entry pointer is assumed to be a specific pointer to native code (of the target machine) that can be legitimately called with the arguments described by the calling convention (a metadata token for a stand-alone signature). Such a pointer can be created using the OpCodes.Ldftn or OpCodes.Ldvirtftn instructions, or passed in from native code.

The calling convention is not checked dynamically, so code that uses a calli instruction does not work correctly if the destination does not actually use the specified calling convention.

The arguments are placed on the stack in left-to-right order. That is, the first argument is computed and placed on the stack, then the second argument, then the third, until all necessary arguments are atop the stack in descending order. The argument-building code sequence for an instance or virtual method must push that instance reference (which must not be a null reference) before any of the user-visible arguments.

System.Security.SecurityException may be thrown if the system security does not grant the caller access to the called method. The security check can occur when the Microsoft Intermediate Language (MSIL) instructions are converted to native code rather than at runtime.

The following ILGenerator.EmitCalli(OpCode, System.Reflection.CallingConventions, Type, Type[], Type[]) methods can be used to perform a calli instruction on the stack. Note that calli should be called through the below methods rather than using the ILGenerator.Emit(OpCode) class to place the instruction directly on the stack.

  • ILGenerator.EmitCalli(Opcode, CallingConventions, Type, Type[], Type[]) for calls using a managed calling convention.

  • ILGenerator.EmitCalli(Opcode, CallingConvention, Type, Type[]) for calls using an unmanaged calling convention.

Requirements

Namespace: System.Reflection.Emit
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0