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)).
무엇 우리 여기서 누락 된거야?
public interface IAnimal //IInterfaceA
public interface ICat : IAnimal //IInterfaceB
public interface IDog : IAnimal //another IInterfaceB
IAnimal someAnimal = GetMeADog();
ICat catAndDogsDontMix = (ICat)someAnimal; //ouch!
당신은 지금 이해하고 수행
public interface IInterfaceB : IInterfaceA
이의이 이해하기 쉽게 이름을 넣어 보자 :
public interface IInterfaceB: IInterfaceB
현실에 있습니다
처음에는 컴파일 할 코드가 없습니다. –
두 개의 간섭이 관련되어 있다는 표시는 없습니다. 이에 따라 [mcve] 지침과 [편집] 글을 읽으십시오. –