_MethodBase.Invoke 方法

定义

为 COM 对象提供对 Invoke 方法的与版本无关的访问。Provides COM objects with version-independent access to the Invoke method.

重载

Invoke(Object, Object[])

为 COM 对象提供对 Invoke(Object, Object[]) 方法的与版本无关的访问。Provides COM objects with version-independent access to the Invoke(Object, Object[]) method.

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

为 COM 对象提供对 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.

注解

此方法用于从非托管代码访问托管类,不应从托管代码调用。This method is for access to managed classes from unmanaged code and should not be called from managed code.

Invoke方法调用由具有指定参数的实例反映的构造函数。The Invoke methods invoke the constructor reflected by the instance that has the specified parameters.

Invoke(Object, Object[])

为 COM 对象提供对 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

参数

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. 如果不存在任何参数,则 parameters 应为 nullIf there are no parameters, parameters should be null.

如果此实例表示的方法或构造函数采用 ref(在 Visual Basic 中为 ByRef)参数,则使用此函数调用该方法或构造函数时,该参数不需要特殊的特性。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. 对于引用类型元素,此值为 nullFor reference type elements, this value is null. 对于值类型元素,此值为 0、0.0 或 false,具体取决于特定的元素类型。For value type elements, this value is 0, 0.0, or false, depending on the specific element type.

返回

与构造函数关联的类的实例。An instance of the class associated with the constructor.

注解

此方法用于从非托管代码访问托管类,不应从托管代码调用。This method is for access to managed classes from unmanaged code and should not be called from managed code.

Invoke方法使用指定的参数调用此对象所表示的方法或构造函数。The Invoke method invokes the method or constructor represented by this object, using the specified parameters.

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

为 COM 对象提供对 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

参数

obj
Object

创建了此方法的实例。The instance that created this method.

invokeAttr
BindingFlags

指定绑定类型的 BindingFlags 值之一。One of the BindingFlags values that specifies the type of binding.

binder
Binder

一个 Binder,它定义一组属性并通过反射来启用绑定、自变量类型强制转换和成员调用。A Binder that defines a set of properties and enables the binding, coercion of argument types, and invocation of members using reflection. 如果 bindernull,则使用 Binder.DefaultBindingIf binder is null, then Binder.DefaultBinding is used.

parameters
Object[]

Object 类型的数组,该类型用于在 binder 的约束下匹配此构造函数的参数的个数、顺序和类型。An array of type Object used to match the number, order, and type of the parameters for this constructor, under the constraints of binder. 如果此构造函数不需要参数,则像 Object[] parameters = new Object[0] 中那样传递一个包含零元素的数组。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. 对于引用类型元素,此值为 nullFor reference type elements, this value is null. 对于值类型元素,此值为 0、0.0 或 false,具体取决于特定的元素类型。For value type elements, this value is 0, 0.0, or false, depending on the specific element type.

culture
CultureInfo

用于控制类型强制的 CultureInfo 对象。A CultureInfo object used to govern the coercion of types. 如果这是 null,则使用当前线程的 CultureInfoIf this is null, the CultureInfo for the current thread is used.

返回

与构造函数关联的类的实例。An instance of the class associated with the constructor.

注解

此方法用于从非托管代码访问托管类,不应从托管代码调用。This method is for access to managed classes from unmanaged code and should not be called from managed code.

方法使用指定的参数在指定Binder对象ConstructorInfo的约束下,用指定的参数来调用反射的构造函数。 InvokeThe Invoke method invokes the constructor reflected by this ConstructorInfo object with the specified arguments, under the constraints of the specified Binder object.

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)

参数

dispIdMember
UInt32

成员的标识符。An identifier for the member.

riid
Guid

留待将来使用。Reserved for future use. 必须为 IID_NULL。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

指向一个结构的指针,该结构包含一个自变量数组、一个命名自变量的 DISPID 自变量数组和数组中元素数的计数。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

指向结果存储位置的指针。A pointer to the location where the result will be stored.

pExcepInfo
IntPtr

指向一个包含异常信息的结构的指针。A pointer to a structure that contains exception information.

puArgErr
IntPtr

第一个出错参数的索引。The index of the first argument that has an error.

注解

此方法用于从非托管代码访问托管类,不应从托管代码调用。This method is for access to managed classes from unmanaged code and should not be called from managed code. 有关IDispatch::Invoke的详细信息,请参阅 MSDN library。For more information about IDispatch::Invoke, see the MSDN Library.

适用于