EventInfoAddEventHandler Method |
Adds an event handler to an event source.
Namespace: System.ReflectionAssembly: mscorlib (in mscorlib.dll) Version: 4.0.0.0
Syntax public virtual void AddEventHandler(
Object target,
Delegate handler
)
Parameters
- target
- Type: SystemObject
The event source. - handler
- Type: SystemDelegate
Encapsulates a method or methods to be invoked when the event is raised by the target.
Exceptions Exception | Condition |
---|
InvalidOperationException | The event does not have a public add accessor. |
ArgumentException | The handler that was passed in cannot be used. |
MethodAccessException | The caller does not have access permission to the member. |
TargetException | The target parameter is null and the event is not static.-or- The EventInfo is not declared on the target. |
See Also