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!

TypeBuilder.InvokeMember

Invokes the specified member. The method that is to be invoked must be accessible and provide the most specific match with the specified argument list, under the contraints of the specified binder and invocation attributes.

[Visual Basic]
Overrides Public Function InvokeMember( _
   ByVal name As String, _
   ByVal invokeAttr As BindingFlags, _
   ByVal binder As Binder, _
   ByVal target As Object, _
   ByVal args() As Object, _
   ByVal modifiers() As ParameterModifier, _
   ByVal culture As CultureInfo, _
   ByVal namedParameters() As String _
) As Object
[C#]
public override object InvokeMember(
   string name,
   BindingFlags invokeAttr,
   Binder binder,
   object target,
   object[] args,
   ParameterModifier[] modifiers,
   CultureInfo culture,
   string[] namedParameters
);
[C++]
public: override Object* InvokeMember(
   String* name,
   BindingFlags invokeAttr,
   Binder* binder,
   Object* target,
   Object* args[],
   ParameterModifier* modifiers[],
   CultureInfo* culture,
   String* namedParameters[]
);
[JScript]
public override function InvokeMember(
   name : String,
   invokeAttr : BindingFlags,
   binder : Binder,
   target : Object,
   args : Object[],
   modifiers : ParameterModifier[],
   culture : CultureInfo,
   namedParameters : String[]
) : Object;

Parameters

name
The name of the member to invoke. This may be a constructor, method, property, or field. A suitable invocation attribute must be specified. Note that it is possible to invoke the default member of a class by passing an empty string as the name of the member.
invokeAttr
The invocation attribute. This must be a bit flag from BindingFlags.
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.
target
The object on which to invoke the specified member. If the member is static, this parameter is ignored.
args
An argument list. This is an array of Objects that contains the number, order, and type of the parameters of the member to be invoked. If there are no parameters this should be null.
modifiers
An array of the same length as args with elements that represent the attributes associated with the arguments of the member to be invoked. A parameter has attributes associated with it in the metadata. They are used by various interoperability services. See the metadata specs for details such as this.
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.)
namedParameters
This array of parameter names match up starting at element zero with the args array. That args[0] is matched with the parameter named namedParamaters[0] etc. There must be no "wholes" in the array. If args.Length > namedParameters.Length, the remain parameters are filled in order.

Return Value

Returns the return value of the invoked member.

Exceptions

Exception Type Condition
NotSupportedException This method is not currently supported.

Remarks

A method will be invoked if the number of parameters in the method declaration equals the number of arguments in the specified argument list, and the type of each argument can be converted by the binder to the type of the parameter.

The binder will find all of the matching methods. These methods are found based upon the type of binding requested (BindingFlags.InvokeMethod, BindingFlags.GetProperties, etc.). The set of methods is filtered by the name, number of arguments, and a set of search modifiers defined in the binder. After the method is selected, it will be invoked. Accessability is checked at that point. The search may control which set of methods are searched based upon the accessibility attribute associated with the method. The IBinder.BindToMethod method is responsible for selecting the method to be invoked. The default binder selects the most specific match.

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.This method is not currently supported. As a workaround, retrieve the type using Type.GetType or Assembly.GetType and use reflection on the retrieved type.

See Also

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