Windows apps
Collapse the table of content
Expand the table of content
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.

ModuleBuilder::DefineGlobalMethod Method (String^, MethodAttributes, CallingConventions, Type^, array<Type^>^, array<Type^>^, array<Type^>^, array<array<Type^>^>^, array<array<Type^>^>^)

 

Defines a global method with the specified name, attributes, calling convention, return type, custom modifiers for the return type, parameter types, and custom modifiers for the parameter types.

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

public:
MethodBuilder^ DefineGlobalMethod(
	String^ name,
	MethodAttributes attributes,
	CallingConventions callingConvention,
	Type^ returnType,
	array<Type^>^ requiredReturnTypeCustomModifiers,
	array<Type^>^ optionalReturnTypeCustomModifiers,
	array<Type^>^ parameterTypes,
	array<array<Type^>^>^ requiredParameterTypeCustomModifiers,
	array<array<Type^>^>^ optionalParameterTypeCustomModifiers
)

Parameters

name
Type: System::String^

The name of the method. name cannot contain embedded null characters.

attributes
Type: System.Reflection::MethodAttributes

The attributes of the method. attributes must include Static.

callingConvention
Type: System.Reflection::CallingConventions

The calling convention for the method.

returnType
Type: System::Type^

The return type of the method.

requiredReturnTypeCustomModifiers
Type: array<System::Type^>^

An array of types representing the required custom modifiers for the return type, such as IsConst or IsBoxed. If the return type has no required custom modifiers, specify null.

optionalReturnTypeCustomModifiers
Type: array<System::Type^>^

An array of types representing the optional custom modifiers for the return type, such as IsConst or IsBoxed. If the return type has no optional custom modifiers, specify null.

parameterTypes
Type: array<System::Type^>^

The types of the method's parameters.

requiredParameterTypeCustomModifiers
Type: array<array<System::Type^>^>^

An array of arrays of types. Each array of types represents the required custom modifiers for the corresponding parameter of the global method. If a particular argument has no required custom modifiers, specify null instead of an array of types. If the global method has no arguments, or if none of the arguments have required custom modifiers, specify null instead of an array of arrays.

optionalParameterTypeCustomModifiers
Type: array<array<System::Type^>^>^

An array of arrays of types. Each array of types represents the optional custom modifiers for the corresponding parameter. If a particular argument has no optional custom modifiers, specify null instead of an array of types. If the global method has no arguments, or if none of the arguments have optional custom modifiers, specify null instead of an array of arrays.

Return Value

Type: System.Reflection.Emit::MethodBuilder^

The defined global method.

Exception Condition
ArgumentException

The method is not static. That is, attributes does not include Static.

-or-

An element in the Type array is null.

ArgumentNullException

name is null.

InvalidOperationException

The CreateGlobalFunctions method has been previously called.

This overload is provided for designers of managed compilers.

You cannot use the global method that this method defines until you call CreateGlobalFunctions.

System_CAPS_noteNote

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.

.NET Framework
Available since 2.0
Silverlight
Available since 2.0
Return to top
Show:
© 2017 Microsoft