0
我有一個返回一個接口引用IInterfaceA
的方法,並希望將其轉換爲IInterfaceB
這樣做:演員到子接口
IInterfaceA a = SomeMethodThatReturnAnIInterfaceA();
IInterfaceB b = (IInterfaceB)a;
public IInterfaceA : OtherInterfaceA, OtherInterfaceB {}
public IInterfaceB : IInterfaceB {}
但在運行時我得到:
Unable to cast COM object of type 'OPCAutomation.OPCGroupClass' to interface
type 'SemaforosNNM.OPC.OPCDaGroup'. This operation failed because the
QueryInterface call on the COM component for the interface with IID
'{70F93164-7F80-37E3-8EFB-DAB08298316E}' failed due to the following error:
Interfaz no compatible (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
什麼我們在這裏失蹤了嗎?
那麼你缺少的代碼將編譯,初學者。 –
沒有跡象表明兩個干涉是相關的。閱讀[mcve]指導並[相應地發佈]。 –