.tlh generated on 2 machines is different

只愿长相守 提交于 2019-12-03 14:22:49

You can use the rename attribute for the import to explicitly rename the properties. Say you have propA that sometimes becomes PropA and propB that sometimes becomes PropB. To always have PropA and PropB use rename as follows:

#import <library> rename( "propA", "PropA" ) rename( "propB", "PropB" )

Use this with care - it causes a simple text substitution that works for any identifiers it encounters in the type library. In some cases it can cause hard to debug undesired side effects.

Ed Sykes

I'm having the same problem.

Via another SO question ( https://stackoverflow.com/questions/708721/compare-type-libraries-generated-by-tlbexp ) I found this piece of community content:

http://social.msdn.microsoft.com/Forums/en-US/clr/thread/5003c486-ed3f-4ec8-8398-a1251b0f9e74

Quoting from that content:

In the documentation of tlbexp, there is one useful community content:

http://msdn2.microsoft.com/en-gb/library/hfzzah2c(VS.80).aspx

Quote:

"The reason for the /names option is that type libraries store each identifier in a case-insensitive table. The first case encountered wins. So a class called Monitor might end up being exposed as "monitor" if there's a parameter with such a name encountered first. (And the order in which identifiers are encountered can vary simply by recompiling your assembly!) /names can guarantee stable casing."

The root cause seems to be a bug in the midl, described here:

http://support.microsoft.com/default.aspx?scid=kb;en-us;220137

Quote:

"When there are two identifiers that differ only by case, the case of the second identifier is changed to reflect the case of the first."

So as a solution, I unchecked the option "register for COM interop" in the project settings and added the post-build-steps

"$(DevEnvDir)....\SDK\v2.0\Bin\tlbexp" $(TargetFileName) /names:"$(ProjectDir)Names.txt" %windir%\Microsoft.NET\Framework\v2.0.50727\regasm $(TargetFileName)

The names file contains the entriesthat define how capizalization should be done. In my case it contains only one line:

ID

Best Regards

Bernd Ritter

Using the /names has solved this problem for me.

Sanity check: are you absolutely sure the same #import directive is used on both machines? i.e. the same exactly source files being compiled?

Try creating a network share over the directory containing the project and open it on the other machine in order to be 1000% sure these are the same source files being compiled.

Sorry I don't have any more specific suggestions.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!