Table of Contents

Method InvokeMember

Namespace
Microsoft.Samples.Debugging.CorMetadata
Assembly
corapi.dll

InvokeMember(string, BindingFlags, Binder, object, object[], ParameterModifier[], CultureInfo, string[])

When overridden in a derived class, invokes the specified member, using the specified binding constraints and matching the specified argument list, modifiers and culture.

public override object InvokeMember(string name, BindingFlags invokeAttr, Binder binder, object target, object[] args, ParameterModifier[] modifiers, CultureInfo culture, string[] namedParameters)

Parameters

name string

The string containing the name of the constructor, method, property, or field member to invoke.-or- An empty string ("") to invoke the default member. -or-For IDispatch members, a string representing the DispID, for example "[DispID=3]".

invokeAttr BindingFlags

A bitmask comprised of one or more BindingFlags that specify how the search is conducted. The access can be one of the BindingFlags such as Public, NonPublic, Private, InvokeMethod, GetField, and so on. The type of lookup need not be specified. If the type of lookup is omitted, BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static are used.

binder Binder

An object that defines a set of properties and enables binding, which can involve selection of an overloaded method, coercion of argument types, and invocation of a member through reflection.-or- A null reference (Nothing in Visual Basic), to use the DefaultBinder. Note that explicitly defining a Binder object may be required for successfully invoking method overloads with variable arguments.

target object

The object on which to invoke the specified member.

args object[]

An array containing the arguments to pass to the member to invoke.

modifiers ParameterModifier[]

An array of ParameterModifier objects representing the attributes associated with the corresponding element in the args array. A parameter's associated attributes are stored in the member's signature. The default binder processes this parameter only when calling a COM component.

culture CultureInfo

The CultureInfo object representing the globalization locale to use, which may be necessary for locale-specific conversions, such as converting a numeric String to a Double.-or- A null reference (Nothing in Visual Basic) to use the current thread's CultureInfo.

namedParameters string[]

An array containing the names of the parameters to which the values in the args array are passed.

Returns

object

An object representing the return value of the invoked member.

Exceptions

ArgumentNullException

invokeAttr does not contain CreateInstance and name is null.

ArgumentException

args and modifiers do not have the same length.-or- invokeAttr is not a valid BindingFlags attribute.-or- invokeAttr does not contain one of the following binding flags: InvokeMethod, CreateInstance, GetField, SetField, GetProperty, or SetProperty.-or- invokeAttr contains CreateInstance combined with InvokeMethod, GetField, SetField, GetProperty, or SetProperty.-or- invokeAttr contains both GetField and SetField.-or- invokeAttr contains both GetProperty and SetProperty.-or- invokeAttr contains InvokeMethod combined with SetField or SetProperty.-or- invokeAttr contains SetField and args has more than one element.-or- The named parameter array is larger than the argument array.-or- This method is called on a COM object and one of the following binding flags was not passed in: BindingFlags.InvokeMethod, BindingFlags.GetProperty, BindingFlags.SetProperty, BindingFlags.PutDispProperty, or BindingFlags.PutRefDispProperty.-or- One of the named parameter arrays contains a string that is null.

MethodAccessException

The specified member is a class initializer.

MissingFieldException

The field or property cannot be found.

MissingMethodException

No method can be found that matches the arguments in args.-or- No member can be found that has the argument names supplied in namedParameters.-or- The current Type object represents a type that contains open type parameters, that is, ContainsGenericParameters returns true.

TargetException

The specified member cannot be invoked on target.

AmbiguousMatchException

More than one method matches the binding criteria.

InvalidOperationException

The method represented by name has one or more unspecified generic type parameters. That is, the method's System.Reflection.MethodInfo.ContainsGenericParameters property returns true.