Upraviť

Zdieľať cez


_MethodBase.Invoke Method

Definition

Provides COM objects with version-independent access to the Invoke method.

Overloads

Invoke(Object, Object[])

Provides COM objects with version-independent access to the Invoke(Object, Object[]) method.

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

Provides COM objects with version-independent access to the Invoke(Object, BindingFlags, Binder, Object[], CultureInfo) method.

Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Provides access to properties and methods exposed by an object.

Remarks

This method is for access to managed classes from unmanaged code and should not be called from managed code.

The Invoke methods invoke the constructor reflected by the instance that has the specified parameters.

Invoke(Object, Object[])

Provides COM objects with version-independent access to the Invoke(Object, Object[]) method.

public:
 System::Object ^ Invoke(System::Object ^ obj, cli::array <System::Object ^> ^ parameters);
public object Invoke (object obj, object[] parameters);
abstract member Invoke : obj * obj[] -> obj
Public Function Invoke (obj As Object, parameters As Object()) As Object

Parameters

obj
Object

The instance that created this method.

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, parameters should be null.

If the method or constructor represented by this instance takes a ref parameter (ByRef in Visual Basic), no special attribute is required for that parameter 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.

Returns

An instance of the class associated with the constructor.

Remarks

This method is for access to managed classes from unmanaged code and should not be called from managed code.

The Invoke method invokes the method or constructor represented by this object, using the specified parameters.

Applies to

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

Provides COM objects with version-independent access to the Invoke(Object, BindingFlags, Binder, Object[], CultureInfo) method.

public:
 System::Object ^ Invoke(System::Object ^ obj, System::Reflection::BindingFlags invokeAttr, System::Reflection::Binder ^ binder, cli::array <System::Object ^> ^ parameters, System::Globalization::CultureInfo ^ culture);
public object Invoke (object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, object[] parameters, System.Globalization.CultureInfo culture);
abstract member Invoke : obj * System.Reflection.BindingFlags * System.Reflection.Binder * obj[] * System.Globalization.CultureInfo -> obj
Public Function Invoke (obj As Object, invokeAttr As BindingFlags, binder As Binder, parameters As Object(), culture As CultureInfo) As Object

Parameters

obj
Object

The instance that created this method.

invokeAttr
BindingFlags

One of the BindingFlags values that specifies the type of binding.

binder
Binder

A Binder that defines a set of properties and enables the binding, coercion of argument types, and invocation of members using reflection. If binder is null, then Binder.DefaultBinding is used.

parameters
Object[]

An array of type Object used to match the number, order, and type of the parameters for this constructor, under the constraints of binder. If this constructor does not require parameters, pass an array with zero elements, as in Object[] parameters = new Object[0]. 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

A CultureInfo object used to govern the coercion of types. If this is null, the CultureInfo for the current thread is used.

Returns

An instance of the class associated with the constructor.

Remarks

This method is for access to managed classes from unmanaged code and should not be called from managed code.

The Invoke method invokes the constructor reflected by this ConstructorInfo object with the specified arguments, under the constraints of the specified Binder object.

Applies to

Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Provides access to properties and methods exposed by an object.

public:
 void Invoke(System::UInt32 dispIdMember, Guid % riid, System::UInt32 lcid, short wFlags, IntPtr pDispParams, IntPtr pVarResult, IntPtr pExcepInfo, IntPtr puArgErr);
public void Invoke (uint dispIdMember, ref Guid riid, uint lcid, short wFlags, IntPtr pDispParams, IntPtr pVarResult, IntPtr pExcepInfo, IntPtr puArgErr);
abstract member Invoke : uint32 * Guid * uint32 * int16 * nativeint * nativeint * nativeint * nativeint -> unit
Public Sub Invoke (dispIdMember As UInteger, ByRef riid As Guid, lcid As UInteger, wFlags As Short, pDispParams As IntPtr, pVarResult As IntPtr, pExcepInfo As IntPtr, puArgErr As IntPtr)

Parameters

dispIdMember
UInt32

An identifier for the member.

riid
Guid

Reserved for future use. Must be IID_NULL.

lcid
UInt32

The locale context in which to interpret arguments.

wFlags
Int16

Flags describing the context of the call.

pDispParams
IntPtr

nativeint

A pointer to a structure containing an array of arguments, an array of argument DISPIDs for named arguments, and counts for the number of elements in the arrays.

pVarResult
IntPtr

nativeint

A pointer to the location where the result will be stored.

pExcepInfo
IntPtr

nativeint

A pointer to a structure that contains exception information.

puArgErr
IntPtr

nativeint

The index of the first argument that has an error.

Remarks

This method is for access to managed classes from unmanaged code and should not be called from managed code. For more information, see IDispatch::Invoke.

Applies to