Rediger

Del via


ConstructorBuilder.Invoke Method

Definition

Invokes the constructor dynamically reflected by this instance.

Overloads

Invoke(BindingFlags, Binder, Object[], CultureInfo)

Dynamically invokes the constructor represented by this instance on the given object, passing along the specified parameters, and under the constraints of the given binder.

Invoke(Object, BindingFlags, Binder, Object[], CultureInfo)

Dynamically invokes the constructor reflected by this instance with the specified arguments, under the constraints of the specified Binder.

Invoke(BindingFlags, Binder, Object[], CultureInfo)

Source:
ConstructorBuilder.cs

Dynamically invokes the constructor represented by this instance on the given object, passing along the specified parameters, and under the constraints of the given binder.

public:
 override System::Object ^ Invoke(System::Reflection::BindingFlags invokeAttr, System::Reflection::Binder ^ binder, cli::array <System::Object ^> ^ parameters, System::Globalization::CultureInfo ^ culture);
public override object Invoke (System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder? binder, object?[]? parameters, System.Globalization.CultureInfo? culture);
public override object Invoke (System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, object[] parameters, System.Globalization.CultureInfo culture);
override this.Invoke : System.Reflection.BindingFlags * System.Reflection.Binder * obj[] * System.Globalization.CultureInfo -> obj
Public Overrides Function Invoke (invokeAttr As BindingFlags, binder As Binder, parameters As Object(), culture As CultureInfo) As Object

Parameters

invokeAttr
BindingFlags

This must be a bit flag from BindingFlags, such as InvokeMethod, NonPublic, and so on.

binder
Binder

An object that enables the binding, coercion of argument types, invocation of members, and retrieval of MemberInfo objects using reflection. If binder is null, the default binder is used. See Binder.

parameters
Object[]

An argument list. This is an array of arguments with the same number, order, and type as the parameters of the constructor to be invoked. If there are no parameters this should be null.

culture
CultureInfo

An instance of CultureInfo used to govern the coercion of types. If this is null, the CultureInfo for the current thread is used. (For example, this is necessary to convert a String that represents 1000 to a Double value, since 1000 is represented differently by different cultures.)

Returns

The value returned by the invoked constructor.

Exceptions

Remarks

If the constructor has no parameters, the value of the parameters parameter should be null. Otherwise, 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.

For example, if the constructor reflected by this instance is declared as public class taking two strings, then the parameters parameter should be an array of Object with length 2.

Note

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.

See also

Applies to

Invoke(Object, BindingFlags, Binder, Object[], CultureInfo)

Source:
ConstructorBuilder.cs

Dynamically invokes the constructor reflected by this instance with the specified arguments, under the constraints of the specified Binder.

public:
 override System::Object ^ Invoke(System::Object ^ obj, System::Reflection::BindingFlags invokeAttr, System::Reflection::Binder ^ binder, cli::array <System::Object ^> ^ parameters, System::Globalization::CultureInfo ^ culture);
public override object Invoke (object? obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder? binder, object?[]? parameters, System.Globalization.CultureInfo? culture);
public override object Invoke (object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, object[] parameters, System.Globalization.CultureInfo culture);
override this.Invoke : obj * System.Reflection.BindingFlags * System.Reflection.Binder * obj[] * System.Globalization.CultureInfo -> obj
Public Overrides Function Invoke (obj As Object, invokeAttr As BindingFlags, binder As Binder, parameters As Object(), culture As CultureInfo) As Object

Parameters

obj
Object

The object that needs to be reinitialized.

invokeAttr
BindingFlags

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

binder
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.

parameters
Object[]

An argument list. This is an array of arguments with the same number, order, and type as the parameters of the constructor to be invoked. If there are no parameters, this should be a null reference (Nothing in Visual Basic).

culture
CultureInfo

A CultureInfo used to govern the coercion of types. If this is null, the CultureInfo for the current thread is used.

Returns

An instance of the class associated with the constructor.

Exceptions

Remarks

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.

See also

Applies to