Click or drag to resize
DelegateCreateDelegate Method (Type, Object, MethodInfo, Boolean)
Creates a delegate of the specified type that represents the specified static or instance method, with the specified first argument and the specified behavior on failure to bind.

Namespace: System
Assembly: mscorlib (in mscorlib.dll) Version: 4.0.0.0
Syntax
C#
public static Delegate CreateDelegate(
	Type type,
	Object firstArgument,
	MethodInfo method,
	bool throwOnBindFailure
)

Parameters

type
Type: SystemType
A Type representing the type of delegate to create.
firstArgument
Type: SystemObject
An Object that is the first argument of the method the delegate represents. For instance methods, it must be compatible with the instance type.
method
Type: System.ReflectionMethodInfo
The MethodInfo describing the static or instance method the delegate is to represent.
throwOnBindFailure
Type: SystemBoolean
true to throw an exception if method cannot be bound; otherwise, false.

Return Value

Type: Delegate
A delegate of the specified type that represents the specified static or instance method, or null if throwOnBindFailure is false and the delegate cannot be bound to method.
Exceptions
ExceptionCondition
ArgumentNullExceptiontype is null.-or- method is null.
ArgumentExceptiontype does not inherit MulticastDelegate.-or-type is not a RuntimeType. See Runtime Types in Reflection. -or-method cannot be bound, and throwOnBindFailure is true.-or-method is not a RuntimeMethodInfo. See Runtime Types in Reflection.
MissingMethodExceptionThe Invoke method of type is not found.
MethodAccessExceptionThe caller does not have the permissions necessary to access method.
See Also