tlbexp.exe改变方法名“案 [英] tlbexp.exe changes method names' case

查看:197
本文介绍了tlbexp.exe改变方法名“案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个很奇怪的问题。
我出口从C#库COM接口。
我已经启用了注册COM项目的设置,所以它调用tlbexp.exe使类型库。

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...

例如

interface IFoo
{
void randomClass()
}

class RandomClass
{
}

在类型lib中导出的IFoo定义IFoo-> RandomClass()而不是IFoo-> 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?

推荐答案

由于COM不区分大小写,既randomClass和randomClass是在输出库的表相同的符号。 (这就是为什么.NET指引建议PascalCasing的类名和方法的原因之一。)

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!

您可以选择一个或另一个,使用tlbexp的 /名称参数,但两者外壳的无法的共存于库中。

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

要使用tlbexp的名字的文件,您只需创建一个文件与标识符列表,每行一个:

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

RandomClass
SomeOtherIdentifier

然后调用它像这样:

tlbexp MyAssembly.dll /names=MyNames.txt

tlbexp将然后使用所定义的符号的版本names文件。

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

这篇关于tlbexp.exe改变方法名“案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆