MIDL CoClass derived from Interface defined in the same file

3

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 IMyInterfaceB; /* error when I remove rem */
    };

}

1>midl\oleaut32.dll : error MIDL2020: error generating type library : LayOut failed : IMyInterfaceB (0x800288C6

com
typelib
midl
asked on Stack Overflow Aug 8, 2011 by Rebeka Fox • edited Nov 25, 2014 by VividD

3 Answers

1

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:

answered on Stack Overflow Aug 9, 2011 by Rebeka Fox
1

You need use different values of id attributes in the base and inherited interfaces.

answered on Stack Overflow Jan 30, 2012 by vpp
0

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"

answered on Stack Overflow Nov 14, 2014 by StalePhish

User contributions licensed under CC BY-SA 3.0