Case sensitivities

So my team produces Interop Assemblies for Visual Studio. Chris on my team does a great job maintaining a set of monster perl scripts and a batch file that processes IDL's into TLB's into Interop Assemblies. Most people just recommend using TLBIMP on the TLB, but for nasty interfaces which violate OLE Automation rules, you have to muck with the IL directly. (More on this in a future entry.)

So we use MIDL, TLBIMP, ILDASM & ILASM + those perl scripts to create assemblies for interop for the VS interfaces. Great in theory, but the devil is in the details.

There's a strange behavior in MIDL (& TLBIMP also possibly) where the case of some names change during compilation. For instance in the IDL you might have:

interace IFoo : IUnknown


HRESULT GetFoobar([out, retval] BSTR * pbstrFoobar);


In the TLB after TLBIMP you might have:



Yes, that's right IFoo.GetFoo
ar (as in CAPITAL "B")!

and in the Interop Assembly, of course we end up with:


So I was implementing IFoo.GetFoobar in my managed code and it all worked great. I changed some things that are unrelated to the interface and method names and bang! Now the C# compiler is complaining that I haven't implemented IFoo.GetFooBar. Things like this really are difficult to find since it appears that something else was wrong (like missing references). Hey, why can't the C# compiler complain that there's a problem, notice a similar method only differing by case and mention this as a possible cause?

Maybe I'll switch to VB.

Skip to main content