DynamicILInfo Class

DynamicILInfo Class

 

Provides support for alternative ways to generate the Microsoft intermediate language (MSIL) and metadata for a dynamic method, including methods for creating tokens and for inserting the code, exception handling, and local variable signature blobs.

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

System.Object
  System.Reflection.Emit.DynamicILInfo

[ComVisibleAttribute(true)]
public class DynamicILInfo

NameDescription
System_CAPS_pubpropertyDynamicMethod

Gets the dynamic method whose body is generated by the current instance.

NameDescription
System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetTokenFor(Byte[])

Gets a token, valid in the scope of the current DynamicILInfo, representing the signature for the associated dynamic method.

System_CAPS_pubmethodGetTokenFor(DynamicMethod)

Gets a token, valid in the scope of the current DynamicILInfo, representing a dynamic method to be called from the associated method.

System_CAPS_pubmethodGetTokenFor(RuntimeFieldHandle)

Gets a token, valid in the scope of the current DynamicILInfo, representing a field to be accessed from the associated dynamic method.

System_CAPS_pubmethodGetTokenFor(RuntimeFieldHandle, RuntimeTypeHandle)

Gets a token, valid in the scope of the current DynamicILInfo, representing a field to be accessed from the associated dynamic method; the field is on the specified generic type.

System_CAPS_pubmethodGetTokenFor(RuntimeMethodHandle)

Gets a token, valid in the scope of the current DynamicILInfo, representing a method to be accessed from the associated dynamic method.

System_CAPS_pubmethodGetTokenFor(RuntimeMethodHandle, RuntimeTypeHandle)

Gets a token, valid in the scope of the current DynamicILInfo, representing a method on a generic type.

System_CAPS_pubmethodGetTokenFor(RuntimeTypeHandle)

Gets a token, valid in the scope of the current DynamicILInfo, representing a type to be used in the associated dynamic method.

System_CAPS_pubmethodGetTokenFor(String)

Gets a token, valid in the scope of the current DynamicILInfo, representing a string literal to be used in the associated dynamic method.

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_pubmethodSetCode(Byte*, Int32, Int32)

Sets the code body of the associated dynamic method.

System_CAPS_pubmethodSetCode(Byte[], Int32)

Sets the code body of the associated dynamic method.

System_CAPS_pubmethodSetExceptions(Byte*, Int32)

Sets the exception metadata for the associated dynamic method.

System_CAPS_pubmethodSetExceptions(Byte[])

Sets the exception metadata for the associated dynamic method.

System_CAPS_pubmethodSetLocalSignature(Byte*, Int32)

Sets the local variable signature that describes the layout of local variables for the associated dynamic method.

System_CAPS_pubmethodSetLocalSignature(Byte[])

Sets the local variable signature that describes the layout of local variables for the associated dynamic method.

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

The DynamicILInfo class allows developers to write their own MSIL generators instead of using ILGenerator.

To create instances of other types, call methods, and so on, the MSIL you generate must include tokens for those entities. The DynamicILInfo class provides several overloads of the GetTokenFor method, which return tokens valid in the scope of the current DynamicILInfo. For example, if you need to call an overload of the Console.WriteLine method, you can obtain a RuntimeMethodHandle for that overload and pass it to the GetTokenFor method to obtain a token to embed in your MSIL.

Once you have created Byte arrays for your local variable signature, exceptions, and code body, you can use the SetCode, SetExceptions, and SetLocalSignature methods to insert them into the DynamicMethod associated with your DynamicILInfo object.

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". The documentation is available online; see ECMA C# and Common Language Infrastructure Standards on MSDN and Standard ECMA-335 - Common Language Infrastructure (CLI) on the Ecma International Web site.

System_CAPS_noteNote

Do not use DynamicILInfo to generate code that creates a delegate to another dynamic method by calling the delegate constructor directly. Instead, use the CreateDelegate method to create the delegate. A delegate that is created with the delegate constructor does not have a reference to the target dynamic method. The dynamic method might be reclaimed by garbage collection while the delegate is still in use.

.NET Framework
Available since 2.0

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show:
© 2016 Microsoft