Delegate.CreateDelegate Method (Type, Type, String, Boolean)
[ 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 static method of the specified class, with the specified case-sensitivity.
Assembly: mscorlib (in mscorlib.dll)
'Declaration Public Shared Function CreateDelegate ( _ type As Type, _ target As Type, _ method As String, _ ignoreCase As Boolean _ ) As Delegate
- Type: System.Type
The type of delegate to create.
- Type: System.Type
The class that implements method.
- Type: System.String
The name of the static method that the delegate is to represent.
- Type: System.Boolean
true to ignore the case when comparing the name of the method; otherwise, false.
Return ValueType: System.Delegate
A delegate of the specified type that represents the specified static method of the specified class.
type is Nothing.
target is Nothing.
method is Nothing.
type does not inherit MulticastDelegate.
type is not a RuntimeType.
target is not a RuntimeType.
target is an open generic type. That is, its ContainsGenericParameters property is true.
method is not a static method (Shared method in Visual Basic).
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 static 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, Type, String, Boolean, Boolean) method overload, and specifying 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.