Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

DynamicMethod Constructor (String, MethodAttributes, CallingConventions, Type, Type[], Module, Boolean)

Note: This constructor is new in the .NET Framework version 2.0.

Creates a dynamic method that is global to a module, specifying the method name, attributes, calling convention, return type, parameter types, module, and whether just-in-time (JIT) visibility checks should be skipped for members of all types in the module.

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

public DynamicMethod (
	string name,
	MethodAttributes attributes,
	CallingConventions callingConvention,
	Type returnType,
	Type[] parameterTypes,
	Module m,
	bool skipVisibility
)
public DynamicMethod (
	String name, 
	MethodAttributes attributes, 
	CallingConventions callingConvention, 
	Type returnType, 
	Type[] parameterTypes, 
	Module m, 
	boolean skipVisibility
)
public function DynamicMethod (
	name : String, 
	attributes : MethodAttributes, 
	callingConvention : CallingConventions, 
	returnType : Type, 
	parameterTypes : Type[], 
	m : Module, 
	skipVisibility : boolean
)

Parameters

name

The name of the dynamic method. Can be a zero-length string, but not a null reference (Nothing in Visual Basic).

attributes

A bitwise combination of MethodAttributes values that specifies the attributes of the dynamic method. The only combination allowed is Public and Static.

callingConvention

The calling convention for the dynamic method. Must be Standard.

returnType

A Type object that specifies the return type of the dynamic method, or a null reference (Nothing in Visual Basic) if the method has no return type.

parameterTypes

An array of Type objects specifying the types of the parameters of the dynamic method, or a null reference (Nothing in Visual Basic) if the method has no parameters.

m

A Module representing the module with which the dynamic method is to be logically associated.

skipVisibility

true to skip JIT visibility checks on members of all types in all modules; otherwise, false.

Exception typeCondition

ArgumentException

An element of parameterTypes is a null reference (Nothing in Visual Basic) or Void.

ArgumentNullException

name is a null reference (Nothing in Visual Basic).

-or-

m is a null reference (Nothing in Visual Basic).

NotSupportedException

attributes is a combination of flags other than Public and Static.

-or-

callingConvention is not Standard.

-or-

returnType is a type for which Type.IsByRef returns true.

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

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0

Community Additions

Show:
© 2014 Microsoft