如何在没有 RegAsm.exe 的情况下注册类型库
我想知道是否可以在不使用 RegAsm 工具。这是我的情况,希望能够解释我为什么要这样做:
我正在 .NET 中开发一个程序集,它将为我们较旧的 VB6 应用程序提供一些现代功能。我已使用 RegAsm 在我的开发计算机上成功注册了程序集和类型库,如下所示:
regasm.exe MyAssembly.dll /tlb /codebase
上面的命令生成类型库 (MyAssembly.tlb) 并注册它以及注册程序集。我需要注册类型库,以便我可以在 VB6 中使用 Intellisense。
我使用此方法的问题是,在生成类型库文件时,我没有与使用 TlbExp.exe。特别是,我需要使用 TlbExp 的 /names 标志来 指定我的属性名称的正确大小写(RegAsm 屠宰了它们)。那么,如果我使用 TlbExp 生成 tlb 文件,有什么方法可以将其与程序集注册过程分开注册吗?
编辑: da_m_n 的回答对于我提出的问题是正确的。然而,我错误地认为,仅仅因为 RegAsm 可以注册类型库,就必须注册 tlb 才能在 VB6 中引用它。因此,现在我正在注册程序集并使用固定名称引用未注册的 TlbExp 生成的 tlb。
I want to know if it's possible to register a type library without using the RegAsm tool. Here is my situation, which will hopefully explain why I want to do this:
I'm developing an assembly in .NET that will provide some modern functionality for our older VB6 applications. I have successfully registered the assembly and the type library on my development machine using RegAsm like so:
regasm.exe MyAssembly.dll /tlb /codebase
The above command generates the type library (MyAssembly.tlb) and registers it as well as registering the assembly. I need the type library registered so that I can have Intellisense in VB6.
My problem with this method is that I don't have the same level of control when generating the type library file as I do with TlbExp.exe. In particular, I need to use TlbExp's /names flag to specify the proper case of my property names (RegAsm butchers them). So if I use TlbExp to generate my tlb file, is there any way that I can register it separately from the assembly registration process?
Edit: da_m_n's answer is correct for the question I asked. However, I was under the faulty assumption that just because RegAsm could register a type library that it was necessary to register the tlb in order reference it in VB6. So for now I'm registering the assembly and referencing the unregistered, TlbExp-generated tlb with the fixed names.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用regtlib.exe注册tlbexp生成的tlb文件。
Use regtlib.exe to register the tlbexp generated tlb file.
regtlib.exe
在 Win10 平台上不可用。使用相应 .NET SDK 中的相应TlbExp.exe
(例如"%ProgramFiles(x86)%\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.2 Tools \TlbExp.exe" "$(TargetDir)$(TargetFileName)"
请参阅https:// /learn.microsoft.com/en-us/dotnet/framework/tools/tlbexp-exe-type-library-exporter)。regtlib.exe
is not available on Win10 platforms. Use the appropriateTlbExp.exe
as found in the corresponding .NET SDK (e.g."%ProgramFiles(x86)%\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.2 Tools\TlbExp.exe" "$(TargetDir)$(TargetFileName)"
see https://learn.microsoft.com/en-us/dotnet/framework/tools/tlbexp-exe-type-library-exporter).