Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

MethodBuilder.SetMethodBody Method

.NET Framework 4.6 and 4.5

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)

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

Parameters

il
Type: System.Byte()

An array that contains valid MSIL instructions.

maxStack
Type: System.Int32

The maximum stack evaluation depth.

localSignature
Type: System.Byte()

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

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

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

tokenFixups
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 Nothing if the method has no tokens that have to be modified.

ExceptionCondition
ArgumentNullException

il is Nothing.

ArgumentOutOfRangeException

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.

InvalidOperationException

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

-or-

This method was called previously on this MethodBuilder object.

.NET Framework

Supported in: 4.6, 4.5
Show:
© 2015 Microsoft