MethodBuilder.SetMethodBody(Byte[], Int32, Byte[], IEnumerable<ExceptionHandler>, IEnumerable<Int32>) 方法

定义

通过使用 Microsoft 中间语言 (MSIL) 指令指定的字节数组创建方法的主体。Creates the body of the method by using a specified byte array of Microsoft intermediate language (MSIL) instructions.

public:
 void SetMethodBody(cli::array <System::Byte> ^ il, int maxStack, cli::array <System::Byte> ^ localSignature, System::Collections::Generic::IEnumerable<System::Reflection::Emit::ExceptionHandler> ^ exceptionHandlers, System::Collections::Generic::IEnumerable<int> ^ tokenFixups);
public void SetMethodBody (byte[] il, int maxStack, byte[] localSignature, System.Collections.Generic.IEnumerable<System.Reflection.Emit.ExceptionHandler> exceptionHandlers, System.Collections.Generic.IEnumerable<int> tokenFixups);
member this.SetMethodBody : byte[] * int * byte[] * seq<System.Reflection.Emit.ExceptionHandler> * seq<int> -> unit
Public Sub SetMethodBody (il As Byte(), maxStack As Integer, localSignature As Byte(), exceptionHandlers As IEnumerable(Of ExceptionHandler), tokenFixups As IEnumerable(Of Integer))

参数

il
Byte[]

包含有效 MSIL 指令的数组。An array that contains valid MSIL instructions.

maxStack
Int32

最大堆栈评估深度。The maximum stack evaluation depth.

localSignature
Byte[]

包含序列化本地变量结构的字节数组。An array of bytes that contain the serialized local variable structure. 如果此方法不具有任何本地变量,则指定 nullSpecify null if the method has no local variables.

exceptionHandlers
IEnumerable<ExceptionHandler>

包含此方法的异常处理程序的集合。A collection that contains the exception handlers for the method. 如果此方法没有异常处理程序,则指定 nullSpecify null if the method has no exception handlers.

tokenFixups
IEnumerable<Int32>

表示 il 中的偏移量的值的集合,其中的每个值指定可以修改的令牌起始点。A collection of values that represent offsets in il, each of which specifies the beginning of a token that may be modified. 如果此方法没有需要修改的令牌,则指定 nullSpecify null if the method has no tokens that have to be modified.

例外

ilnullil is null.

maxStack 为负数。maxStack is negative.

- 或 --or- 其中一个 exceptionHandlers 指定 il 外部的偏移量。One of exceptionHandlers specifies an offset outside of il.

- 或 --or- 其中一个 tokenFixups 指定 il 数组外部的偏移量。One of tokenFixups specifies an offset that is outside the il array.

该包含类型是以前使用 CreateType() 方法创建的。The containing type was previously created using the CreateType() method.

- 或 --or- 之前已在此 MethodBuilder 对象上调用过此方法。This method was called previously on this MethodBuilder object.

适用于