Export (0) Print
Expand All

EventInfo.RemoveEventHandler Method

Removes an event handler from an event source.

[Visual Basic]
Public Sub RemoveEventHandler( _
   ByVal target As Object, _
   ByVal handler As Delegate _
)
[C#]
public void RemoveEventHandler(
 object target,
 Delegate handler
);
[C++]
public: void RemoveEventHandler(
 Object* target,
 Delegate* handler
);
[JScript]
public function RemoveEventHandler(
   target : Object,
 handler : Delegate
);

Parameters

target
The event source.
handler
The delegate to be disassociated from the events raised by target.

Exceptions

Exception Type Condition
InvalidOperationException The MethodInfo returned by GetAddMethod is a null reference (Nothing in Visual Basic).
ArgumentException The handler that was passed in cannot be used.
TargetException The target parameter is a null reference (Nothing in Visual Basic) and the event is not static.

-or-

The EventInfo is not declared on the target.

MethodAccessException The caller does not have access permission to the member.

Remarks

This method attempts to remove the delegate that may synchronize this event on the target object.

When an event is raised by target, the method or methods encapsulated by handler will no longer be invoked.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

.NET Framework Security: 

See Also

EventInfo Class | EventInfo Members | System.Reflection Namespace | Object | Delegate | EventHandler

Show:
© 2015 Microsoft