Can I use a *.tlb file without using Regasm to register it on the computer

狂风中的少年 提交于 2019-12-06 05:50:21

Regasm.exe only creates a type library when you run it with the /tlb:filename.tlb command line option. Which you then use in a VB6 project with Project + References, Browse button to pick the .tlb file. Running Tlbexp.exe is another way to get it, minus the registration. And the one you ought to prefer, the "Register for COM interop" option in the IDE. You however have to run VS elevated so it can write the registry. Right-click the shortcut and select "Run as Administrator".

Having it appear in the VB6 list is a small convenience but that is hard to get. The standard .NET registration code called by Regasm.exe doesn't write the required "Programmable" key to get VB6 to add the component to its list automatically. You have to write a custom registration function decorated by the [ComRegisterFunction] attribute that writes the missing key. It isn't worth it when you can simply click Browse.

Also note that you do not have to register the type library on the user's machine. It is only needed by the VB6 compiler. You do have to register the [ComVisible] classes, it is easy with a Setup project. Just set the Register property of the DLL to vsdrpCOM.

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