Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

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.

Namespace: System.Reflection
Assembly: mscorlib (in mscorlib.dll)

public abstract Object Invoke (
	BindingFlags invokeAttr,
	Binder binder,
	Object[] parameters,
	CultureInfo culture
)
public abstract Object Invoke (
	BindingFlags invokeAttr, 
	Binder binder, 
	Object[] parameters, 
	CultureInfo culture
)
public abstract function Invoke (
	invokeAttr : BindingFlags, 
	binder : Binder, 
	parameters : Object[], 
	culture : CultureInfo
) : Object

Parameters

invokeAttr

One of the BindingFlags values that specifies the type of binding.

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 a null reference (Nothing in Visual Basic), then Binder.DefaultBinding is used.

parameters

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[0]. 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 a null reference (Nothing in Visual Basic). For value-type elements, this value is 0, 0.0, or false, depending on the specific element type.

culture

A CultureInfo used to govern the coercion of types. If this is a null reference (Nothing in Visual Basic), the CultureInfo for the current thread is used.

Return Value

An instance of the class associated with the constructor.

Exception typeCondition

ArgumentException

The parameters array does not contain values that match the types accepted by this constructor, under the constraints of the binder.

TargetInvocationException

The invoked constructor throws an exception.

TargetParameterCountException

An incorrect number of parameters was passed.

NotSupportedException

Creation of TypedReference, ArgIterator, and RuntimeArgumentHandle types is not supported.

SecurityException

The caller does not have the necessary code access permissions.

MemberAccessException

The class is abstract.

-or-

The constructor is a class initializer.

MethodAccessException

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.

  • ReflectionPermission  when invoked late-bound through mechanisms such as System.Type.InvokeMember. Associated enumeration: ReflectionPermissionFlag.MemberAccess.
  • ReflectionPermission  for reflecting non-public objects. Associated enumeration: ReflectionPermissionFlag.MemberAccess

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

Community Additions

Show:
© 2015 Microsoft