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]指导并[相应地发布]。 –