Partager via


ModuleBuilder.DefineGlobalMethod Method (String, MethodAttributes, CallingConventions, Type, array<Type[], array<Type[], array<Type[], array<array<Type[][], array<array<Type[][])

Microsoft Silverlight will reach end of support after October 2021. Learn more.

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)

Syntax

'Declaration
Public Function DefineGlobalMethod ( _
    name As String, _
    attributes As MethodAttributes, _
    callingConvention As CallingConventions, _
    returnType As Type, _
    requiredReturnTypeCustomModifiers As Type(), _
    optionalReturnTypeCustomModifiers As Type(), _
    parameterTypes As Type(), _
    requiredParameterTypeCustomModifiers As Type()(), _
    optionalParameterTypeCustomModifiers As Type()() _
) As MethodBuilder
public MethodBuilder DefineGlobalMethod(
    string name,
    MethodAttributes attributes,
    CallingConventions callingConvention,
    Type returnType,
    Type[] requiredReturnTypeCustomModifiers,
    Type[] optionalReturnTypeCustomModifiers,
    Type[] parameterTypes,
    Type[][] requiredParameterTypeCustomModifiers,
    Type[][] optionalParameterTypeCustomModifiers
)

Parameters

  • name
    Type: System.String
    The name of the method. name cannot contain embedded null characters.
  • 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 nulla null reference (Nothing in Visual Basic).
  • 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 nulla null reference (Nothing in Visual Basic).
  • 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 nulla null reference (Nothing in Visual Basic) instead of an array of types. If the global method has no arguments, or if none of the arguments have required custom modifiers, specify nulla null reference (Nothing in Visual Basic) 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 nulla null reference (Nothing in Visual Basic) instead of an array of types. If the global method has no arguments, or if none of the arguments have optional custom modifiers, specify nulla null reference (Nothing in Visual Basic) instead of an array of arrays.

Return Value

Type: System.Reflection.Emit.MethodBuilder
The defined global method.

Exceptions

Exception Condition
ArgumentException

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

-or-

An element in the Type array is nulla null reference (Nothing in Visual Basic).

ArgumentNullException

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

InvalidOperationException

The CreateGlobalFunctions method has been previously called.

Remarks

Important noteImportant Note:

In Silverlight, global methods can be called only by code in the dynamic module.

This overload is provided for designers of managed compilers.

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

Version Information

Silverlight

Supported in: 5, 4, 3

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.