Windows Dev Center

EventInfo.RemoveEventHandler Method

Removes an event handler from an event source.

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

public virtual void RemoveEventHandler(
	Object target,
	Delegate handler
)

Parameters

target
Type: System.Object
The event source.
handler
Type: System.Delegate
The delegate to be unhooked from the event source.

ExceptionCondition
InvalidOperationException

The event does not have a public remove accessor.

ArgumentException

The handler that was passed in cannot be used.

TargetException

The target parameter is null and the event is not static.

-or-

The EventInfo is not declared on the target.

MemberAccessException

This member is invoked late-bound through mechanisms such as Type.InvokeMember.

Use the AddEventHandler method to hook up events in late-bound scenarios.

This method attempts to unhook an event handler for the current event on the event source specified by target, by calling the remove accessor.

NoteNote:

In reflection, the remove accessor can be obtained by calling the GetRemoveMethod method.

For an example, see the AddEventHandler method.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2015 Microsoft