We are supporting an aging VB6 system that we have written new code for in .Net, put the code into assemblies and then exported *.tlb files for use with the VB6 codebase.
My question is, on every computer I wish to run the code on, do I have to use Regasm to register the type libraries?
I ask because it gets difficult to keep track of type library installations as computers break, new computers get added etc. Also, if we update the .Net code, we need to go around every computer and re-register the type library.
To sum up, is it possible to run .Net code from VB6 without having to register the type library on each computer the code is running on?
Thankyou
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.