tags:

views:

32

answers:

2

We have an idl file with multiple interfaces defined, two of which have somehting like this:

[
     object,
     uuid(79E24BAA-DC12-4caf-91DD-2A4D47FED30A),
     helpstring("ISomeInterface Interface"),
     pointer_default(unique)
]
interface ISomeInterface: IUnknown
{
     [propget, id(2)] HRESULT SOMEMethod([out, retval] BSTR* pValue);
};

[
    object,
    uuid(834421B6-511D-457D-B50C-69E7E1B65471),
    dual,
    nonextensible,
    helpstring("IACompleteDifferentInterface Interface"),
    pointer_default(unique)
]
interface IACompleteDifferentInterface : IDispatch
{
   [propget, helpstring("property SomeMethod")] HRESULT SomeMethod([out, retval] BSTR* pVal);
   [propput, helpstring("property SomeMethod")] HRESULT SomeMethod([in] BSTR newVal);
}

They are two completely unrelated interfaces, that happen to have one method with the same name (although with different casing as shown). Everything seems ok, however when we try to compile a project that calls

ISomeInterface -> SOMEMethod 

we get an error saying it doesn't exist. If we call

ISomeInterface -> SomeMethod 

it compiles just fine.

If we rename either method it also compiles ok. I wouldn't expect a naming collision in two different interfaces but that appears to be what's happening.

We can fix it by simply renaming one of them, but i'd really like to understand the problem. Can anyone explain it for me? Thanks

A: 

The IDL seems fine to me. There must be a problem with how the resulting type library is being imported in to your app.

Check your #import statements. Is there a rename attribute changing "SOMEMethod" to "SomeMethod", or ISomeInterface to IACompleteDifferentInterface?

Look in headers that were auto-generated by the #import. You may find a clue in there.

John Dibling
+2  A: 

Psychic debugging powerz tells me that you are using the type library in a managed project. The .NET type library importer (Tlbimp.exe) has an obscure bug, it improperly capitalizes a method or property name if it appears more than once in the library. It uses the capitalization of the first one it encounters.

The first approach is to ignore it, the managed code could just use the identifier with the wrong capitalization. Or you could upgrade the importer, I'm fairly sure this bug was fixed in this one.

Hans Passant
Thanks, your phsyic debugging abilities are astounding we are using it in a managed c# project (i would have included that information had it crossed my mind that it was relevant), so your answer is probably correct. I'll try the new tlbimp you suggested, thanks.
John C