ConstructorBuilder.SetMethodBody Method

Definition

Creates the body of the constructor by using a specified byte array of Microsoft intermediate language (MSIL) instructions.

C#
public void SetMethodBody (byte[] il, int maxStack, byte[] localSignature, System.Collections.Generic.IEnumerable<System.Reflection.Emit.ExceptionHandler> exceptionHandlers, System.Collections.Generic.IEnumerable<int> tokenFixups);

Parameters

il
Byte[]

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. Specify null if the constructor has no local variables.

exceptionHandlers
IEnumerable<ExceptionHandler>

A collection that contains the exception handlers for the constructor. Specify null if the constructor has no exception handlers.

tokenFixups
IEnumerable<Int32>

A collection of values that represent offsets in il, each of which specifies the beginning of a token that may be modified. Specify null if the constructor has no tokens that have to be modified.

Exceptions

il is null.

maxStack is negative.

-or-

One of exceptionHandlers specifies an offset outside of il.

-or-

One of tokenFixups specifies an offset that is outside the il array.

The containing type was previously created using the CreateType() method.

-or-

This method was called previously on this ConstructorBuilder object.

Applies to

Product Versions
.NET Framework 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