System.Reflection.Emit.DynamicMethod.CreateDelegate Method

Completes the dynamic method and creates a delegate that can be used to execute it.

Syntax

[System.Runtime.InteropServices.ComVisible(true)]
public override sealed Delegate CreateDelegate (Type delegateType)

Parameters

delegateType
A delegate type whose signature matches that of the dynamic method.

Returns

A delegate of the specified type, which can be used to execute the dynamic method.

Remarks

Calling the DynamicMethod.CreateDelegate(Type) method or the erload:System.Reflection.Emit.DynamicMethod.Invoke method completes the dynamic method. Any further attempt to alter the dynamic method, such as modifying parameter definitions or emitting more Microsoft intermediate language (MSIL), is ignored; no exception is thrown.

To create a method body for a dynamic method when you have your own MSIL generator, call the DynamicMethod.GetDynamicILInfo method to obtain a System.Reflection.Emit.DynamicILInfo object. If you do not have your own MSIL generator, call the erload:System.Reflection.Emit.DynamicMethod.GetILGenerator method to obtain an System.Reflection.Emit.ILGenerator object that can be used to generate the method body.

Requirements

Namespace: System.Reflection.Emit
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 2.0.0.0, 4.0.0.0
Since: .NET 2.0