tags:

views:

37

answers:

2

I have this old C++ COM component. I took the latest code base, built it and found that one of the properties has become lower case. For example, in the pre-compiled dll i have a property "Type", but when building from source it's called "type". The idl shows that the property is called "Type". So what could possibly be happening here?

+1  A: 

After rubbing my crystal ball for a while, it concluded that you are using the .NET Tlbimp.exe utility to convert the type library to a .NET interop class. It has a bug, it gets the identifier casing wrong if there's a symbol in the type library with the same name but different case. Like a method declaration earlier in the type library that takes an argument named "type". Any identifier named "Type" in the rest of the type library will get converted to "type".

An improved version of the utility is available here.

Hans Passant
Actually I am simply talking about viewing the library in OLEVIEW so not .Net involved at this point. However, possibly by some coincidence what you say is happening in this case. I looked at recent changes.. a new method had been added with a param named "type". I then commented this any the "Type" property was displayed correctly. I then uncommented it.. and.. it works!?? huh? using VC++6 IDE for this component so not shocked, just a little frustrated.Thanks for the quick response.
Mr AH
Interesting, sure makes it sound that the bug is actually located in the GetTypeLib implementation provided by COM.
Hans Passant
Not a bug - see my answer...
Porges
+1  A: 

COM is case-insensitive, so there is only one entry in the library's symbol table for the symbol "type". The version which is put into the symbol table is the first one that the compiler encounters.

Microsoft's advice on the matter is simply:

Make sure that the same name is not already present in the IDL file when introducing a new identifier.

You should stick to either Type or type in the IDL, for consistent results.

Porges