MIDL CoClass derived from Interface defined in the same file
Why can't I define an Interface in an idl file and then have a CoClass derive it in a library block within the same file when I am deriving said Interface from an Interface that I have defined in another Proxy Server project?
[
object,
uuid(00000000-0000-0000-0000-000000000000),
pointer_default(unique)
] interface IMyInterfaceB: IMyInterfaceA
{
[id(1), helpstring("")]
HRESULT NewMethod();
}
[
uuid(10000000-0000-0000-0000-000000000000),
helpstring("Type Library 1.00"),
version(1.00)
]
library MyLibrary
{
importlib("stdole32.tlb");
importlib("stdole2.tlb");
[
uuid(20000000-0000-0000-0000-000000000001),
helpstring("My Class")
]
coclass CMyClass
{
interface IMyInterfaceA;
//interface IMyInterface开发者_如何学JAVAB; /* error when I remove rem */
};
}
1>midl\oleaut32.dll : error MIDL2020: error generating type library : LayOut failed : IMyInterfaceB (0x800288C6
As Hans Passant pointed out I shouldn't pick GUID's, the generator should be used to generate them. Although this wasn't the problem it was similar in nature. I wasn't following a proper ID schema when defining my interfaces as until now it hadn't been important.
I guess I will be rereading the appropriate section in COM Programming w/ Microsoft .NET. I found the reason when I tried out the error look-up tool for the first time, having exposed its existence by turning on Visual Studios Advanced Mode feature.
Lessons Learned :/
BekaD:
You need use different values of id
attributes in the base and inherited interfaces.
User "vpp" was right on with this one. I just experienced this error myself when trying to make a new interface inheriting from another so I could overload one of the methods. I copy and pasted the entire thing from the original interface but didn't change the "id(1)" part to be a new unique number so I was also receiving "error MIDL2020: error generating type library : LayOut failed"
精彩评论