MethodBuilder.SetMethodBody Method (Byte(), Int32, Byte(), IEnumerable(Of ExceptionHandler), IEnumerable(Of Int32))

.NET Framework (current version)

The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

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

Namespace:   System.Reflection.Emit
Assembly:  mscorlib (in mscorlib.dll)

Public Sub SetMethodBody (
	il As Byte(),
	maxStack As Integer,
	localSignature As Byte(),
	exceptionHandlers As IEnumerable(Of ExceptionHandler),
	tokenFixups As IEnumerable(Of Integer)


Type: System.Byte()

An array that contains valid MSIL instructions.

Type: System.Int32

The maximum stack evaluation depth.

Type: System.Byte()

An array of bytes that contain the serialized local variable structure. Specify null if the method has no local variables.

Type: System.Collections.Generic.IEnumerable(Of ExceptionHandler)

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

Type: System.Collections.Generic.IEnumerable(Of 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 method has no tokens that have to be modified.

Exception Condition

il is null.


maxStack is negative.


One of exceptionHandlers specifies an offset outside of il.


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


The containing type was previously created using the TypeBuilder.CreateType method.


This method was called previously on this MethodBuilder object.

.NET Framework
Available since 4.5
Return to top