ILGenerator.EmitCalli Metodo
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Inserisce un'istruzione Calli nel flusso MSIL (Intermediate Language) Microsoft.
Overload
| Nome | Descrizione |
|---|---|
| EmitCalli(OpCode, CallingConvention, Type, Type[]) |
Inserisce un'istruzione Calli nel flusso Microsoft MSIL (Intermediate Language), specificando una convenzione di chiamata non gestita per la chiamata indiretta. |
| EmitCalli(OpCode, CallingConventions, Type, Type[], Type[]) |
Inserisce un'istruzione Calli nel flusso Microsoft MSIL (Intermediate Language), specificando una convenzione di chiamata gestita per la chiamata indiretta. |
EmitCalli(OpCode, CallingConvention, Type, Type[])
Inserisce un'istruzione Calli nel flusso Microsoft MSIL (Intermediate Language), specificando una convenzione di chiamata non gestita per la chiamata indiretta.
public:
void EmitCalli(System::Reflection::Emit::OpCode opcode, System::Runtime::InteropServices::CallingConvention unmanagedCallConv, Type ^ returnType, cli::array <Type ^> ^ parameterTypes);
public:
virtual void EmitCalli(System::Reflection::Emit::OpCode opcode, System::Runtime::InteropServices::CallingConvention unmanagedCallConv, Type ^ returnType, cli::array <Type ^> ^ parameterTypes);
public void EmitCalli(System.Reflection.Emit.OpCode opcode, System.Runtime.InteropServices.CallingConvention unmanagedCallConv, Type returnType, Type[] parameterTypes);
public virtual void EmitCalli(System.Reflection.Emit.OpCode opcode, System.Runtime.InteropServices.CallingConvention unmanagedCallConv, Type returnType, Type[] parameterTypes);
member this.EmitCalli : System.Reflection.Emit.OpCode * System.Runtime.InteropServices.CallingConvention * Type * Type[] -> unit
abstract member EmitCalli : System.Reflection.Emit.OpCode * System.Runtime.InteropServices.CallingConvention * Type * Type[] -> unit
override this.EmitCalli : System.Reflection.Emit.OpCode * System.Runtime.InteropServices.CallingConvention * Type * Type[] -> unit
Public Sub EmitCalli (opcode As OpCode, unmanagedCallConv As CallingConvention, returnType As Type, parameterTypes As Type())
Public Overridable Sub EmitCalli (opcode As OpCode, unmanagedCallConv As CallingConvention, returnType As Type, parameterTypes As Type())
Parametri
- unmanagedCallConv
- CallingConvention
Convenzione di chiamata non gestita da utilizzare.
- parameterTypes
- Type[]
Tipi degli argomenti obbligatori per l'istruzione.
Esempio
Nell'esempio di codice seguente viene illustrato l'utilizzo contestuale del EmitCalli metodo per chiamare un metodo di tipo non gestito esterno alla classe dinamica.
MethodBuilder myMthdBuilder = myTypeBuilder.DefineMethod("MyMethod",
MethodAttributes.Public,
returnType, mthdParamTypes);
// We will assume that an external unmanaged type "LegacyNumber" has been loaded, and
// that it has a method "ToString" which returns a string.
MethodInfo unmanagedMthdMI = Type.GetType("LegacyNumber").GetMethod("ToString");
ILGenerator myMthdIL = myMthdBuilder.GetILGenerator();
// Code to emit various IL opcodes here ...
// Load a reference to the specific object instance onto the stack.
myMthdIL.Emit(OpCodes.Ldc_I4, addrOfLegacyNumberObject);
myMthdIL.Emit(OpCodes.Ldobj, Type.GetType("LegacyNumber"));
// Make the call to the unmanaged type method, telling it that the method is
// the member of a specific instance, to expect a string
// as a return value, and that there are no explicit parameters.
myMthdIL.EmitCalli(OpCodes.Calli,
System.Runtime.InteropServices.CallingConvention.ThisCall,
typeof(string),
new Type[] {});
// More IL code emission here ...
Dim myMthdBuilder As MethodBuilder = myTypeBuilder.DefineMethod("MyMethod", _
MethodAttributes.Public, _
returnType, mthdParamTypes)
' We will assume that an external unmanaged type "LegacyNumber" has been loaded, and
' that it has a method "ToString" which returns a string.
Dim unmanagedMthdMI As MethodInfo = Type.GetType("LegacyNumber").GetMethod("ToString")
Dim myMthdIL As ILGenerator = myMthdBuilder.GetILGenerator()
' Code to emit various IL opcodes here ...
' Load a reference to the specific object instance onto the stack.
myMthdIL.Emit(OpCodes.Ldc_I4, addrOfLegacyNumberObject)
myMthdIL.Emit(OpCodes.Ldobj, Type.GetType("LegacyNumber"))
' Make the call to the unmanaged type method, telling it that the method is
' the member of a specific instance, to expect a string
' as a return value, and that there are no explicit parameters.
myMthdIL.EmitCalli(OpCodes.Calli, System.Runtime.InteropServices.CallingConvention.ThisCall, _
GetType(String), New Type() {})
' More IL code emission here ...
Commenti
Usare EmitCalli per inserire un'istruzione Calli nel flusso. Non usare Emit.
Si applica a
EmitCalli(OpCode, CallingConventions, Type, Type[], Type[])
Inserisce un'istruzione Calli nel flusso Microsoft MSIL (Intermediate Language), specificando una convenzione di chiamata gestita per la chiamata indiretta.
public:
void EmitCalli(System::Reflection::Emit::OpCode opcode, System::Reflection::CallingConventions callingConvention, Type ^ returnType, cli::array <Type ^> ^ parameterTypes, cli::array <Type ^> ^ optionalParameterTypes);
public:
virtual void EmitCalli(System::Reflection::Emit::OpCode opcode, System::Reflection::CallingConventions callingConvention, Type ^ returnType, cli::array <Type ^> ^ parameterTypes, cli::array <Type ^> ^ optionalParameterTypes);
public void EmitCalli(System.Reflection.Emit.OpCode opcode, System.Reflection.CallingConventions callingConvention, Type returnType, Type[] parameterTypes, Type[] optionalParameterTypes);
public virtual void EmitCalli(System.Reflection.Emit.OpCode opcode, System.Reflection.CallingConventions callingConvention, Type returnType, Type[] parameterTypes, Type[] optionalParameterTypes);
member this.EmitCalli : System.Reflection.Emit.OpCode * System.Reflection.CallingConventions * Type * Type[] * Type[] -> unit
abstract member EmitCalli : System.Reflection.Emit.OpCode * System.Reflection.CallingConventions * Type * Type[] * Type[] -> unit
override this.EmitCalli : System.Reflection.Emit.OpCode * System.Reflection.CallingConventions * Type * Type[] * Type[] -> unit
Public Sub EmitCalli (opcode As OpCode, callingConvention As CallingConventions, returnType As Type, parameterTypes As Type(), optionalParameterTypes As Type())
Public Overridable Sub EmitCalli (opcode As OpCode, callingConvention As CallingConventions, returnType As Type, parameterTypes As Type(), optionalParameterTypes As Type())
Parametri
- callingConvention
- CallingConventions
Convenzione di chiamata gestita da utilizzare.
- parameterTypes
- Type[]
Tipi degli argomenti obbligatori per l'istruzione.
- optionalParameterTypes
- Type[]
Tipi degli argomenti facoltativi per varargs le chiamate.
Eccezioni
optionalParameterTypes non nullè , ma callingConvention non include il VarArgs flag .
Commenti
Usare EmitCalli per inserire un'istruzione Calli nel flusso. Non usare Emit.
Se optionalParameterTypes specifica argomenti facoltativi, callingConvention deve includere il CallingConventions.VarArgs flag .