System.Reflection.Emit.ConstructorBuilder.Invoke Method

Invokes the constructor dynamically reflected by this instance on the given object, passing along the specified parameters, and under the constraints of the given binder.

Syntax

public override object Invoke (System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, object[] parameters, System.Globalization.CultureInfo culture)

Parameters

invokeAttr
This must be a bit flag from System.Reflection.BindingFlags, such as InvokeMethod, NonPublic, and so on.
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 System.Reflection.Binder.
parameters
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
An instance of System.Globalization.CultureInfo used to govern the coercion of types. If this is null, the System.Globalization.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

Returns an object that is the return value of the invoked constructor.

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.

Requirements

Namespace: System.Reflection.Emit
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0