NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

ConstructorBuilder.Invoke

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

[Visual Basic]
Overrides Public Function Invoke( _
   ByVal invokeAttr As BindingFlags, _
   ByVal binder As Binder, _
   ByVal parameters() As Object, _
   ByVal culture As CultureInfo _
) As Object
[C#]
public override object Invoke(
   BindingFlags invokeAttr,
   Binder binder,
   object[] parameters,
   CultureInfo culture
);
[C++]
public: override Object* Invoke(
   BindingFlags invokeAttr,
   Binder* binder,
   Object* parameters[],
   CultureInfo* culture
);
[JScript]
public override function Invoke(
   invokeAttr : BindingFlags,
   binder : Binder,
   parameters : Object[],
   culture : CultureInfo
) : Object;

Parameters

invokeAttr
This must be a bit flag from BindingFlags: InvokeMethod, NonPublic, etc.
binder
An object that enables the binding, coercion of argument types, invocation of members, and retrieval of MemberInfo objects via reflection. If binder is a null reference (in Visual Basic Nothing), the default binder is used. See 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 a null reference (Nothing).
culture
An instance of CultureInfo used to govern the coercion of types. If this is null, the CultureInfo for the current thread is used. (Note that this is necessary to, for example, convert a String that represents 1000 to a Double value, since 1000 is represented differently by different cultures.)

Return Value

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

Exceptions

Exception Type Condition
NotSupportedException This method is not currently supported. The workaround is to retrieve the constructor using GetConstructor and call Invoke on the returned ConstructorInfo.

Remarks

If the constructor has no parameters, the value of the parameters parameter should be a null reference (Nothing). 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 Foo(String a, String b), then parameters should be an array of Objects 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 via Reflection whenever the code is fully trusted.

See Also

ConstructorBuilder Class | ConstructorBuilder Members | System.Reflection.Emit Namespace