This documentation is archived and is not being maintained.

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.

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

public static readonly OpCode Calli

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


Assembly Format


29 < T >

calli callSiteDescr

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

The stack transitional behavior, in sequential order, is:

  1. Method arguments arg1 through argN are pushed onto the stack.

  2. The method entry pointer is pushed onto the stack.

  3. Method arguments arg1 through argN and the method entry pointer are popped from the stack; the call to the method is performed. When complete, a return value is generated by the callee method and sent to the caller.

  4. The return value is pushed onto the stack.

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 (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 Ldftn or 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.

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 EmitCalli 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 Emit 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.

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.