Calls the method indicated on the evaluation stack (as a pointer to an entry point) with arguments described by a calling convention.
Assembly: mscorlib (in mscorlib.dll)
The following table lists the instruction's hexadecimal and Microsoft Intermediate Language (MSIL) assembly format, along with a brief reference summary:
29 < T >
Calls the method pointed to with arguments described by the calling convention.
The stack transitional behavior, in sequential order, is:
Method arguments arg1 through argN are pushed onto the stack.
The method entry pointer is pushed onto the stack.
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.
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.
Available since 4.5
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Available since 2.0
Windows Phone Silverlight
Available since 7.1
Available since 8.1