System.Reflection.EventInfo.GetAddMethod Method

When overridden in a derived class, retrieves the MethodInfo object for the EventInfo.AddEventHandler(object, Delegate) method of the event, specifying whether to return non-public methods.

Syntax

public abstract MethodInfo GetAddMethod (bool nonPublic)

Parameters

nonPublic
true if non-public methods can be returned; otherwise, false.

Returns

A System.Reflection.MethodInfo object representing the method used to add an event handler delegate to the event source.

Exceptions

TypeReason
MethodAccessException nonPublic is true, the method used to add an event handler delegate is non-public, and the caller does not have permission to reflect on non-public methods.

Remarks

The GetAddMethod initializes and adds the event subscribe method as a Boolean value. The AddEventHandler method is used to add an event-handler delegate to the invocation list of an event source.

Permissions

TypeReason
System.Security.Permissions.ReflectionPermissionRequires permission to reflect non-public members of a type in loaded assemblies. See System.Security.Permissions.ReflectionPermissionFlag.TypeInformation.

Requirements

Namespace: System.Reflection
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0