【发布时间】:2016-09-16 15:12:45
【问题描述】:
我有一个返回接口引用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)).
我们在这里缺少什么?
【问题讨论】:
-
好吧,对于初学者来说,您缺少可以编译的代码。
-
没有迹象表明两个干扰是相关的。请阅读minimal reproducible example 指导和edit 相应帖子。