_MethodInfo.Invoke 方法

定義

為 COM 物件提供與版本無關的 Invoke 方法之存取權。

多載

Invoke(Object, Object[])

為 COM 物件提供與版本無關的 Invoke(Object, Object[]) 方法之存取權。

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

為 COM 物件提供與版本無關的 Invoke(Object, BindingFlags, Binder, Object[], CultureInfo) 方法之存取權。

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

提供物件所公開的屬性和方法的存取權。

備註

這個方法適用於從 Unmanaged 程式代碼存取 Managed 類別,不應從 Managed 程式代碼呼叫。

方法 Invoke 會叫用實例所反映且具有指定參數的建構函式。

Invoke(Object, Object[])

為 COM 物件提供與版本無關的 Invoke(Object, Object[]) 方法之存取權。

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

執行個體,建立這個方法。

parameters
Object[]

叫用方法或建構函式的引數清單。 這是物件陣列,其數目、順序和型別與要叫用的方法或建構函式的參數相同。 如果沒有任何參數,parameters 應該為 null

如果這個執行個體表示的方法或建構函式採用 ref 參數 (在 Visual Basic 中為 ByRef),則該參數就不需要有特殊屬性,就能夠以這個函式叫用方法或建構函式。 此陣列中任何未明確使用值初始化的物件,都會包含該物件類型的預設值。 對於參考型別項目而言,此值為 null。 對於實值型別項目而言,此值為 0、0.0 或 false (需視特定項目型別而定)。

傳回

與建構函式相關聯的類別之執行個體。

備註

方法 Invoke 會使用指定的參數叫用這個 物件所代表的方法或建構函式。

適用於

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

為 COM 物件提供與版本無關的 Invoke(Object, BindingFlags, Binder, Object[], CultureInfo) 方法之存取權。

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

參數

obj
Object

執行個體,建立這個方法。

invokeAttr
BindingFlags

其中一個 BindingFlags 值,指定繫結的型別。

binder
Binder

Binder,會使用反映定義一組屬性和啟用繫結、引數類型強制型轉和成員引動過程。 如果 bindernull,則會使用 Binder.DefaultBinding

parameters
Object[]

Object 型別的陣列,用於比對在 binder 的限制下,這個建構函式的數字、順序和參數的型別。 如果這個建構函式不需要參數,請傳遞具有零個元素的陣列,如同 中的 Object[] parameters = new Object[0]。 此陣列中任何未明確使用值初始化的物件,都會包含該物件類型的預設值。 對於參考型別項目而言,此值為 null。 對於實值型別項目而言,此值為 0、0.0 或 false (需視特定項目型別而定)。

culture
CultureInfo

用來控制型別之強制型轉的 CultureInfo 物件。 如果這是 null,會使用目前執行緒的 CultureInfo

傳回

與建構函式相關聯的類別之執行個體。

備註

這個方法適用於從 Unmanaged 程式代碼存取 Managed 類別,不應從 Managed 程式代碼呼叫。

方法 Invoke 會叫用這個 ConstructorInfo 物件所反映的建構函式,此建構函式具有指定之對象的條件約束下指定的 Binder 自變數。

適用於

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

提供物件所公開的屬性和方法的存取權。

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

成員的識別項。

riid
Guid

保留供未來使用。 必須是 IID_NULL。

lcid
UInt32

地區設定內容,用於解譯引數。

wFlags
Int16

描述呼叫之內容的旗標。

pDispParams
IntPtr

nativeint

結構的指標,此結構包含引數陣列、具名引數之 DISPID 引數的陣列,以及陣列中元素數目的計數。

pVarResult
IntPtr

nativeint

儲存結果的位置指標。

pExcepInfo
IntPtr

nativeint

包含例外狀況資訊之結構的指標。

puArgErr
IntPtr

nativeint

第一個有錯誤的引數索引。

備註

這個方法適用於從 Unmanaged 程式代碼存取 Managed 類別,不應從 Managed 程式代碼呼叫。 如需詳細資訊,請參閱 IDispatch::Invoke

適用於