DynamicILInfo.SetCode Method

Definition

Sets the code body of the associated dynamic method.

Overloads

SetCode(Byte[], Int32)

Sets the code body of the associated dynamic method.

SetCode(Byte*, Int32, Int32)

Sets the code body of the associated dynamic method.

SetCode(Byte[], Int32)

Source:
DynamicILGenerator.cs
Source:
DynamicILGenerator.cs
Source:
DynamicILGenerator.cs

Sets the code body of the associated dynamic method.

C#
public void SetCode(byte[]? code, int maxStackSize);
C#
public void SetCode(byte[] code, int maxStackSize);

Parameters

code
Byte[]

An array that contains the MSIL stream.

maxStackSize
Int32

The maximum number of items on the operand stack when the method is executing.

Remarks

No validity checks are performed on the MSIL stream.

Calling this method a second time replaces the first MSIL stream with the second.

Generating your own metadata and MSIL requires familiarity with the Common Language Infrastructure (CLI) documentation, especially "Partition II: Metadata Definition and Semantics" and "Partition III: CIL Instruction Set". For more information, see ECMA 335 Common Language Infrastructure (CLI).

Applies to

.NET 10 a ďalšie verzie
Produkt Verzie
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.1

SetCode(Byte*, Int32, Int32)

Source:
DynamicILGenerator.cs
Source:
DynamicILGenerator.cs
Source:
DynamicILGenerator.cs

Important

This API is not CLS-compliant.

CLS-compliant alternative
System.Reflection.Emit.DynamicILInfo.SetCode(Byte[], Int32)

Sets the code body of the associated dynamic method.

C#
[System.CLSCompliant(false)]
public void SetCode(byte* code, int codeSize, int maxStackSize);
C#
[System.CLSCompliant(false)]
[System.Security.SecurityCritical]
public void SetCode(byte* code, int codeSize, int maxStackSize);

Parameters

code
Byte*

A pointer to a byte array containing the MSIL stream.

codeSize
Int32

The number of bytes in the MSIL stream.

maxStackSize
Int32

The maximum number of items on the operand stack when the method is executing.

Attributes

Exceptions

code is null and codeSize is greater than 0.

codeSize is less than 0.

Remarks

No validity checks are performed on the MSIL stream.

Calling this method a second time replaces the first MSIL stream with the second.

Generating your own metadata and MSIL requires familiarity with the Common Language Infrastructure (CLI) documentation, especially "Partition II: Metadata Definition and Semantics" and "Partition III: CIL Instruction Set." For more information, see ECMA 335 Common Language Infrastructure (CLI).

Applies to

.NET 10 a ďalšie verzie
Produkt Verzie
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.1