Partager via


ILGenerator.EmitCall Method

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

Puts a call or callvirt instruction onto the Microsoft intermediate language (MSIL) stream to call a varargs method.

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

Syntax

'Declaration
<SecuritySafeCriticalAttribute> _
Public Overridable Sub EmitCall ( _
    opcode As OpCode, _
    methodInfo As MethodInfo, _
    optionalParameterTypes As Type() _
)
[SecuritySafeCriticalAttribute]
public virtual void EmitCall(
    OpCode opcode,
    MethodInfo methodInfo,
    Type[] optionalParameterTypes
)

Parameters

  • optionalParameterTypes
    Type: array<System.Type[]
    The types of the optional arguments if the method is a varargs method; otherwise, nulla null reference (Nothing in Visual Basic).

Exceptions

Exception Condition
ArgumentException

opcode does not specify a method call.

ArgumentNullException

methodInfo is nulla null reference (Nothing in Visual Basic).

Remarks

The EmitCall method is used to emit calls to varargs methods because there is no overload of the Emit method that specifies the parameter types of the variable arguments.

To emit calls to methods that do not use the VarArgs calling convention, use the Emit(OpCode, MethodInfo) method overload.

The EmitCall method does not throw an exception when optional parameter types are specified for a method that is not varargs. However, InvalidProgramException is thrown when the call is executed.

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.