RemoveEventHandler Method

EventInfo.RemoveEventHandler Method (Object, Delegate)

 

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 disassociated from the events raised by target.

Exception Condition
InvalidOperationException

The event does not have a public remove accessor.

ArgumentException

The handler that was passed in cannot be used.

TargetException
System_CAPS_noteNote

In the .NET for Windows Store apps or the , catch Exception instead.

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

-or-

The EventInfo is not declared on the target.

MethodAccessException
System_CAPS_noteNote

In the .NET for Windows Store apps or the , catch the base class exception, MemberAccessException, instead.

The caller does not have access permission to the member.

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.

ReflectionPermission

when invoked late-bound through mechanisms such as Type.InvokeMember. Associated enumeration: ReflectionPermissionFlag.MemberAccess.

Universal Windows Platform
Available since 4.5
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top
Show:
© 2016 Microsoft