Can Windows installer deploy an assembly based on the version of an external application?
-
19-04-2021 - |
Question
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 againstInterop.ExApp.dll
v1 - Installer w/
my.dll
built/linked againstInterop.ExApp.dll
v2 - Installer w/
my.dll
built/linked againstInterop.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?
Solution
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.
OTHER TIPS
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