ConstructorInfo.Invoke Method (BindingFlags, Binder, Object, CultureInfo)
When implemented in a derived class, invokes the constructor reflected by this ConstructorInfo with the specified arguments, under the constraints of the specified Binder.
Assembly: mscorlib (in mscorlib.dll)
public abstract Object Invoke( BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture )
- Type: System.Reflection.BindingFlags
One of the BindingFlags values that specifies the type of binding.
- Type: System.Reflection.Binder
A Binder that defines a set of properties and enables the binding, coercion of argument types, and invocation of members using reflection. If binder is null, then Binder.DefaultBinding is used.
- Type: System.Object
An array of type Object used to match the number, order and type of the parameters for this constructor, under the constraints of binder. If this constructor does not require parameters, pass an array with zero elements, as in Object parameters = new Object. Any object in this array that is not explicitly initialized with a value will contain the default value for that object type. For reference-type elements, this value is null. For value-type elements, this value is 0, 0.0, or false, depending on the specific element type.
Return ValueType: System.Object
An instance of the class associated with the constructor.
The parameters array does not contain values that match the types accepted by this constructor, under the constraints of the binder.
The invoked constructor throws an exception.
An incorrect number of parameters was passed.
The caller does not have the necessary code access permissions.
The class is abstract.
The constructor is a class initializer.
The constructor is private or protected, and the caller lacks ReflectionPermissionFlag.MemberAccess.
The number, type, and order of elements in the parameters array should be identical to the number, type, and order of parameters for the constructor reflected by this instance.
Before calling the constructor, Invoke ensures that the caller has access permission and that the parameters are of the correct number, order and type.
Access restrictions are ignored for fully trusted code. That is, private constructors, methods, fields, and properties can be accessed and invoked using reflection whenever the code is fully trusted.
To create an instance of a value type that has no instance constructors, use the CreateInstance method.
Starting with the .NET Framework version 2.0 Service Pack 1, this method can be used to access non-public members if the caller has been granted ReflectionPermission with the ReflectionPermissionFlag.RestrictedMemberAccess flag and if the grant set of the non-public members is restricted to the caller’s grant set, or a subset thereof. (See Security Considerations for Reflection.)
To use this functionality, your application should target the .NET Framework version 3.5 or later.
for accessing non-public members when the grant set of the non-public members is restricted to the caller's grant set, or a subset thereof. Associated enumeration: ReflectionPermissionFlag.RestrictedMemberAccess
for accessing non-public members regardless of their grant set. Associated enumeration: ReflectionPermissionFlag.MemberAccess
when invoked late-bound through mechanisms such as Type.InvokeMember. Associated enumeration: ReflectionPermissionFlag.MemberAccess.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.