0

I am developing a small program (a dll) in Visual Studio 2010 / .NET 4 that integrates with an external application (we'll call it ExApp) through COM interop. I am generating the interop assemblies myself using TlbImp.exe, as none are provided by the external application. ExApp comes in three popular versions, each with an effectively identical API, but each having a different (and incompatible) generated interop dll. At the moment, that means I have three separate installers:

  • Installer w/ my.dll built/linked against Interop.ExApp.dll v1
  • Installer w/ my.dll built/linked against Interop.ExApp.dll v2
  • Installer w/ my.dll built/linked against Interop.ExApp.dll v3

There must be a better solution than this.

How do I configure Visual Studio / Windows Installer so that I only need one install .exe? Meaning that the installer will detect the version of ExApp, and install the corresponding versions of my.dll and Interop.ExApp.dll.

And a bonus question: Since the ExApp API has not meaningfully changed, how can I compile one version of my.dll to work with any installed version of ExApp?

Andrew Barber
  • 39,603
  • 20
  • 94
  • 123
Scott B
  • 240
  • 3
  • 10
  • 1
    Late binding with the C# *dynamic* keyword or vb.net is an option in COM. Failing that, the installer has to poke the registry to look for the CLSID key. That's custom. – Hans Passant Jan 25 '12 at 00:24

2 Answers2

1

On your Project's References, is the dll's Specific Version set to True or False? you could try setting it to False if its set as True.

This obviously wouldn't prevent a newer version from breaking (API changes), but that appears to be the case currently anyway

John
  • 6,503
  • 3
  • 37
  • 58
  • Unfortunately, this doesn't allow my.dll to pull a different version of Interop.ExApp.dll from the GAC. However, while testing this idea I found that Interop.ExApp.dll v1 works with ExApp v2, so that is helpful. – Scott B Jan 25 '12 at 01:23
  • @ScottB I'm not sure what you mean, that should allow you to use your single DLL for all 3 versions as long as the API is the same. What errors are you getting if you put your dll (with Specific Version set to false) on those machines? – John Jan 25 '12 at 06:44
  • If I run my.dll compiled with Interop.ExApp.dll v1 (with specific version set to false) on a machine where only Interop.ExApp.dll v2 is installed into the GAC, my.dll fails with 'assembly not found'. – Scott B Jan 25 '12 at 15:44
1

Why don't you build the interops with 3 different file names and then create a factory pattern in your application to decide which provider to use at runtime?

I could show you ways of searching the system to install one of 3 mutually exclusive files but I don't think that kind of complexity belongs in the installer. And it would fall apart anyways if someone upgraded the application that you are creating the interop for.

Christopher Painter
  • 54,556
  • 6
  • 63
  • 100