Export (0) Print
Expand All

TypeBuilder.DefineMethod Method (String, MethodAttributes, CallingConventions)

Adds a new method to the type, with the specified name, method attributes, and calling convention.

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

member DefineMethod : 
        name:string * 
        attributes:MethodAttributes * 
        callingConvention:CallingConventions -> MethodBuilder 

Parameters

name
Type: System.String
The name of the method. name cannot contain embedded nulls.
attributes
Type: System.Reflection.MethodAttributes
The attributes of the method.
callingConvention
Type: System.Reflection.CallingConventions
The calling convention of the method.

Return Value

Type: System.Reflection.Emit.MethodBuilder
A MethodBuilder representing the newly defined method.

ExceptionCondition
ArgumentException

The length of name is zero.

-or-

The type of the parent of this method is an interface and this method is not virtual (Overridable in Visual Basic).

ArgumentNullException

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

InvalidOperationException

The type was previously created using CreateType.

-or-

For the current dynamic type, the IsGenericType property is true, but the IsGenericTypeDefinition property is false.

Use this method overload when you do not know the method signature at the time you define the method. For example, the parameter types and return type of a generic method might be specified by the method's generic type parameters, which must be defined after the method has been added to the type. The parameters and return type of the method can be set later using the MethodBuilder.SetSignature method.

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

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

Community Additions

ADD
Show:
© 2014 Microsoft