ILGenerator.EmitCalli Methode
Definitie
Belangrijk
Bepaalde informatie heeft betrekking op een voorlopige productversie die aanzienlijk kan worden gewijzigd voordat deze wordt uitgebracht. Microsoft biedt geen enkele expliciete of impliciete garanties met betrekking tot de informatie die hier wordt verstrekt.
Zet een Calli instructie op de Microsoft tussentaalstroom (MSIL).
Overloads
| Name | Description |
|---|---|
| EmitCalli(OpCode, CallingConvention, Type, Type[]) |
Zet een Calli instructie op de Microsoft tussentaalstroom (MSIL) en geeft een niet-beheerde oproepconventie op voor de indirecte aanroep. |
| EmitCalli(OpCode, CallingConventions, Type, Type[], Type[]) |
Hiermee plaatst u een Calli instructie op de stroom Microsoft tussenliggende taal (MSIL), waarbij een beheerde oproepconventie voor de indirecte aanroep wordt opgegeven. |
EmitCalli(OpCode, CallingConvention, Type, Type[])
Zet een Calli instructie op de Microsoft tussentaalstroom (MSIL) en geeft een niet-beheerde oproepconventie op voor de indirecte aanroep.
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())
Parameters
- unmanagedCallConv
- CallingConvention
De niet-beheerde oproepconventie die moet worden gebruikt.
- parameterTypes
- Type[]
De typen van de vereiste argumenten voor de instructie.
Voorbeelden
In het volgende codevoorbeeld ziet u het contextuele gebruik van de EmitCalli methode om een niet-beheerde typemethode aan te roepen die extern is voor de dynamische klasse.
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 ...
Opmerkingen
Gebruik EmitCalli dit om een Calli instructie op de stroom te plaatsen. Maak geen gebruik van Emit.
Van toepassing op
EmitCalli(OpCode, CallingConventions, Type, Type[], Type[])
Hiermee plaatst u een Calli instructie op de stroom Microsoft tussenliggende taal (MSIL), waarbij een beheerde oproepconventie voor de indirecte aanroep wordt opgegeven.
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())
Parameters
- callingConvention
- CallingConventions
De beheerde oproepconventie die moet worden gebruikt.
- parameterTypes
- Type[]
De typen van de vereiste argumenten voor de instructie.
- optionalParameterTypes
- Type[]
De typen optionele argumenten voor varargs aanroepen.
Uitzonderingen
optionalParameterTypes is niet null, maar callingConvention bevat de VarArgs vlag niet.
Opmerkingen
Gebruik EmitCalli dit om een Calli instructie op de stroom te plaatsen. Maak geen gebruik van Emit.
Als optionalParameterTypes u optionele argumenten opgeeft, callingConvention moet u de CallingConventions.VarArgs vlag opnemen.