Export (0) Print
Expand All

TypeBuilder.DefineMethodOverride Method

Specifies a given method body that implements a given method declaration.

[Visual Basic]
Public Sub DefineMethodOverride( _
   ByVal methodInfoBody As MethodInfo, _
   ByVal methodInfoDeclaration As MethodInfo _
)
[C#]
public void DefineMethodOverride(
 MethodInfo methodInfoBody,
 MethodInfo methodInfoDeclaration
);
[C++]
public: void DefineMethodOverride(
 MethodInfo* methodInfoBody,
 MethodInfo* methodInfoDeclaration
);
[JScript]
public function DefineMethodOverride(
   methodInfoBody : MethodInfo,
 methodInfoDeclaration : MethodInfo
);

Parameters

methodInfoBody
The method body to be used. This should be a MethodBuilder object.
methodInfoDeclaration
The method whose declaration is to be used.

Exceptions

Exception Type Condition
ArgumentException methodInfoBody does not belong to this class.
ArgumentNullException methodInfoBody or methodInfoDeclaration is a null reference (Nothing in Visual Basic).
InvalidOperationException The type was previously created using CreateType.

-or-

The method methodInfoBody 's declaring type is not this type.

Remarks

DefineMethodOverride defines a method impl. A method impl is a token point to an implementation and a token pointing to a declaration that the body will implement. The body must be defined on the type the method impl is defined and the body must be virtual. The declaration can be made to a method defined on an interface implemented by the type, a method on a derived class or a method defined in the type. If the declaration is on an interface only, the slot defined for the interface is altered. If the declaration is made to a method on a base type then the slot for the method is overridden and any duplicates for the overridden method are also replaced. The method overridden cannot be the actual method declared. If the method is on the same type then the slot is replaced and any duplicates for the replaced methods are overridden.

Example

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

TypeBuilder Class | TypeBuilder Members | System.Reflection.Emit Namespace

Show:
© 2015 Microsoft