Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tlbexp.exe changes method names' case

I have a rather strange problem. I am exporting an interface from a C# library to COM. I have enabled the 'register with COM' project setting, so it calls tlbexp.exe to make the type libs.

We use camel case on our method names and I noticed that the exported type library changes these any method that happens to coincide with a class name to Pascal case...

e.g

interface IFoo
{
void randomClass()
}

class RandomClass
{
}

The exported IFoo in the type lib defines IFoo->RandomClass() instead of IFoo->randomClass()

Any ideas on what causes this and how to stop it?

like image 230
ljbade Avatar asked Jun 28 '10 05:06

ljbade


1 Answers

Since COM is case-insensitive, both "RandomClass" and "randomClass" are the same symbol in the output library's table. (This is part of the reason why the .NET guidelines recommend PascalCasing for class names and methods.)

The one that gets chosen will be the first one the compiler emits, and this is fairly non-deterministic from a programmer's point of view!

You can choose one or the other, using tlbexp's /names parameter, but both casings cannot co-exist in the library.

To use tlbexp's names file, you simply create a file with a list of identifiers, one per line:

RandomClass
SomeOtherIdentifier

Then you call it like so:

tlbexp MyAssembly.dll /names=MyNames.txt

tlbexp will then use the version of the symbol defined in the names file.

like image 128
porges Avatar answered Sep 29 '22 16:09

porges