Delegate.CreateDelegate Method (Type, Object, String)
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Creates a delegate of the specified type that represents the specified instance method to invoke on the specified class instance.
Assembly: mscorlib (in mscorlib.dll)
Public Shared Function CreateDelegate ( _ type As Type, _ target As Object, _ method As String _ ) As Delegate
public static Delegate CreateDelegate( Type type, Object target, string method )
The type of delegate to create.
The class instance on which method is invoked.
The name of the instance method that the delegate is to represent.
A delegate of the specified type that represents the specified instance method to invoke on the specified class instance.
type is nullNothingnullptra null reference (Nothing in Visual Basic).
target is nullNothingnullptra null reference (Nothing in Visual Basic).
method is nullNothingnullptra null reference (Nothing in Visual Basic).
type does not inherit MulticastDelegate.
type is not a RuntimeType.
method is not an instance method.
method cannot be bound; for example, because it cannot be found.
The Invoke method of type is not found.
The caller does not have access to method.
Application code attempts to access this member late-bound, for example, by using the Type..::.InvokeMember method.
This method creates delegates for instance methods only. An instance method is a method that is associated with an instance of a class; a static method is a method that is associated with the class itself.
method must specify an accessible method.
This method overload is equivalent to calling the CreateDelegate(Type, Object, String, Boolean, Boolean) method overload, and specifying false for ignoreCase and true for throwOnBindFailure.
CreateDelegate throws MissingMethodException when attempting to create a delegate with incorrect arguments. Delegate..::.CreateDelegate throws TargetInvocationException when called on a null object. Delegate..::.CreateDelegate throws MissingMethodException instead of ArgumentException for non-instance methods.
Windows Phone OS
Supported in: 8.1, 8.0, 7.1, 7.0