Type Library (tlb) file generation and registration in a Visual Sudio setup project

I was trying to create an msi file using the Visual Studio Setup Project that would register one of my ComVisible assemblies and make it available for use within a VB6 application. I found this post, specifically Ian Turner’s response, to be very helpful. The unfortunate side effect of using the RegistrationServices class for registering the assembly for COM Interop was that it does not generate and register the type library.
Now; I have only ever done VB6 on some pretty minor projects and my exposure to it was limited at that. I am not certain why type library generation and registration is necessary, but the VB developer I work with insisted that the type library be registered for him to use it (if anyone knows a method to create the necessary objects in VB6 without requiring type library registration, please post a reply).
In any case, I found a method that will generate the necessary type library and register it (as well as unregister it if the user uninstalls the application) that seems to work. I was lead to this conclusion to a response to the Registering an Assembly for COM Interop in a MSI file with the Windows Installer XML toolset article by Phil Wilson.
Here are the steps I am doing currently (I plan to port this to a nant build script and will post that solution when I get there, for the time being, here’s what I did within Visual Studio):
  1. Add a post-build event to the ComVisible assembly project: "$(DevEnvDir)….SDKv2.0Bintlbexp" $(TargetFileName) /out:com.MyAssemblyName.tlb
  2. Build the target Assembly.
  3. Add the generated tlb file to the Application Folder of the File System items of the Setup project.
  4. Ensure that the Register property of the file (right-click on the file and select Properties) is set to vsdrfCOM.

Of note is that the Register property of the project output for the target assembly (within the Setup project) is set to vsdrpCOM (I didn’t change this so I assume it is the default) which is responsible for registering the assembly for COM Interop. The steps above are resposible for generating and registering the type library.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s