Table of Contents

Method Invoke

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

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

When overridden in a derived class, invokes the reflected method or constructor with the given parameters.

public override object Invoke(object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture)

Parameters

obj object

The object on which to invoke the method or constructor. If a method is static, this argument is ignored. If a constructor is static, this argument must be null or an instance of the class that defines the constructor.

invokeAttr BindingFlags

A bitmask that is a combination of 0 or more bit flags from BindingFlags. If binder is null, this parameter is assigned the value Default; thus, whatever you pass in is ignored.

binder Binder

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

parameters object[]

An argument list for the invoked method or constructor. This is an array of objects with the same number, order, and type as the parameters of the method or constructor to be invoked. If there are no parameters, this should be null.If the method or constructor represented by this instance takes a ByRef parameter, there is no special attribute required for that parameter in order to invoke the method or constructor using this function. Any object in this array that is not explicitly initialized with a value will contain the default value for that object type. For reference-type elements, this value is null. For value-type elements, this value is 0, 0.0, or false, depending on the specific element type.

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. (This is necessary to convert a String that represents 1000 to a Double value, for example, since 1000 is represented differently by different cultures.)

Returns

object

An Object containing the return value of the invoked method, or null in the case of a constructor, or null if the method's return type is void. Before calling the method or constructor, Invoke checks to see if the user has access permission and verifies that the parameters are valid.Elements of the parameters array that represent parameters declared with the ref or out keyword may also be modified.

Exceptions

TargetException

The obj parameter is null and the method is not static.-or- The method is not declared or inherited by the class of obj. -or-A static constructor is invoked, and obj is neither null nor an instance of the class that declared the constructor.

ArgumentException

The type of the parameters parameter does not match the signature of the method or constructor reflected by this instance.

TargetParameterCountException

The parameters array does not have the correct number of arguments.

TargetInvocationException

The invoked method or constructor throws an exception.

MethodAccessException

The caller does not have permission to execute the method or constructor that is represented by the current instance.

InvalidOperationException

The type that declares the method is an open generic type. That is, the ContainsGenericParameters property returns true for the declaring type.