Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

ILGenerator.EmitCall Method

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)
[SecuritySafeCriticalAttribute]
public virtual void EmitCall(
	OpCode opcode,
	MethodInfo methodInfo,
	Type[] optionalParameterTypes
)

Parameters

opcode
Type: System.Reflection.Emit.OpCode
The MSIL instruction to be emitted onto the stream. Must be OpCodes.Call, OpCodes.Callvirt, or OpCodes.Newobj.
methodInfo
Type: System.Reflection.MethodInfo
The varargs method to be called.
optionalParameterTypes
Type: System.Type[]
The types of the optional arguments if the method is a varargs method; otherwise, null.
ExceptionCondition
ArgumentException

opcode does not specify a method call.

ArgumentNullException

methodInfo is null.

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.

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1

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

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.