Udostępnij za pośrednictwem


OpCodes.Calli Field

Microsoft Silverlight will reach end of support after October 2021. Learn more.

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)

Syntax

'Declaration
Public Shared ReadOnly Calli As OpCode
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:

Format

Assembly Format

Description

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 MSIL instructions are converted to native code rather than at runtime.

In the .NET Framework, the ILGenerator.EmitCalli method is used to emit a calli instruction. This method is not supported in Silverlight.

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.