Wednesday, February 6, 2008

Distributing a .Net DLL for use by VB6

The trick is getting the .Net assembly installed into the GAC on your 500+ remote machines. You can do this manually by copying the file into c:\windows\assembly but this won't work via remote scripting. You can use the "gacutil /i {assembly.dll}" but the GacUtil.exe is no longer distributed with the .Net framework (since 2.0) so you have the have the SDK or Visual Studio installed on the client machine - no thanks!

The easiest way is to create an MSI to install the DLL. In fact, this will also copy it and register it, so it saves a few steps; plus you get the uninstall stuff with it. To do this:

1. In your project, add a new "Setup" wizard. Choose "Windows application".

2. Select the "Primary Output" for your DLL project.

3. By default this will install the DLL in your application folder. To install in the GAC, right-click the "File System" in the setup project and choose "Add Special Folder-Global Assembly Cache Folder". Then right click in the new folder and add the primary output of your DLL project.

4. Make sure you set the "Product name" and "Company name" in the properties of the setup project. These are used to build the path to you application folder where the DLL will be copied:

4. Build the Setup project and you'll find a {assemblyname}.msi file sitting in the ".../release/bin" path under your project.

5. Deploy the MSI to your remote machine and run it. Hopefully you have some kind of application deployment tool that can run MSI installs!

No comments: