3
votes

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

3
No repro. The IMyInterfaceA declaration is missing so its difficult to recreate the error. The [source] attribute is almost certainly wrong, only use it for dispinterfaces that generate events. If intended then you need to declare one of them [default]. Don't pick your own guids, use guidgen.exe - Hans Passant
@Hans Passant the above code is generic garbage . . . I don't pick GUID's . . . . I will remove the [source] and am aware of [source,default] . .. I separated the proxy and the object and I find I still get the error when I mention the interface deriving from other than IUnknown in the library block :/ - Rebeka Fox
Post code that actually reproduces the problem. - Hans Passant
It also works fine in another project where I derive from IStorage - Rebeka Fox
@Hans Passant the code is the same whether I call it IMyInterfaceA or my own code . . . . if there is no reason that it shouldn't work than I'll have to keep staring at it :/ - Rebeka Fox

3 Answers

1
votes

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:

1
votes

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

0
votes

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"