DynamicMethod Constructor (String, Type, Type[], Type, Boolean)


Creates a dynamic method, specifying the method name, return type, parameter types, the type with which the dynamic method is logically associated, and whether just-in-time (JIT) visibility checks should be skipped for types and members accessed by the Microsoft intermediate language (MSIL) of the dynamic method.

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

public DynamicMethod(
	string name,
	Type returnType,
	Type[] parameterTypes,
	Type owner,
	bool skipVisibility


Type: System.String

The name of the dynamic method. This can be a zero-length string, but it cannot be null.

Type: System.Type

A Type object that specifies the return type of the dynamic method, or null if the method has no return type.

Type: System.Type[]

An array of Type objects specifying the types of the parameters of the dynamic method, or null if the method has no parameters.

Type: System.Type

A Type with which the dynamic method is logically associated. The dynamic method has access to all members of the type.

Type: System.Boolean

true to skip JIT visibility checks on types and members accessed by the MSIL of the dynamic method; otherwise, false.

Exception Condition

An element of parameterTypes is null or Void.


owner is an interface, an array, an open generic type, or a type parameter of a generic type or method.


name is null.


owner is null.


returnType is null, or is a type for which IsByRef returns true.

The dynamic method created with this constructor has access to all members of the type owner, and to public and internal (Friend in Visual Basic) members of all the other types in the module that contains owner. Skipping the JIT compiler's visibility checks allows the dynamic method to access private and protected members of all other types as well. This is useful, for example, when writing code to serialize objects.

This constructor specifies method attributes MethodAttributes.Public and MethodAttributes.Static, and calling convention CallingConventions.Standard.


For backward compatibility, this constructor demands SecurityPermission with the SecurityPermissionFlag.ControlEvidence flag if the following conditions are both true: owner is in a module other than the calling module, and the demand for ReflectionPermission with the ReflectionPermissionFlag.MemberAccess flag has failed. If the demand for SecurityPermission succeeds, the operation is allowed.


Starting with the .NET Framework 2.0 Service Pack 1, this member no longer requires ReflectionPermission with the ReflectionPermissionFlag.ReflectionEmit flag. (See Security Issues in Reflection Emit.) To use this functionality, your application should target the .NET Framework 3.5 or later.


to skip JIT visibility checks, if skipVisibility is true. Associated enumeration: ReflectionPermissionFlag.MemberAccess.


to associate the dynamic method with a type in a module other than the calling module. Associated enumeration: ReflectionPermissionFlag.RestrictedMemberAccess.

.NET Framework
Available since 2.0
Portable Class Library
Supported in: portable .NET platforms
Available since 2.0
Windows Phone Silverlight
Available since 7.1
Return to top