Visual-studio – Linking against a .dll version older than the installed one in Visual Studio 2005


Please excuse the large amount of background info, but this is a fairly specific question.

I have a Visual Studio 2005 project that creates a .dll file. This project depends on a .dll from another company, "BigCorp", which gets installed with BigCorp's software.

Ideally the dll I create should be usable with any (backwards compatible) version of BigCorp's dll. That is, if I link against version my program should still work if the user upgrades BigCorp's app so that the .dll is version

This is straightforward enough in VS2005, by looking at the project's References, selecting the .dll and making sure the "Specific Version" property is false.

Now for my actual question: Is it possible to specify a base version of the .dll that is older than the one installed on the machine that is building the project? Continuing my previous example, my build machine has version installed, but I want the .dll it generates to be compatible with installations that haven't upgraded, and only have version installed.

It seems that VS resolves the path to the .dll and detects the runtime version based on the file it finds. Trying to override it by specifying the version number directly in the .vbproj or .csproj, i.e.,

<Reference Include="BigCorp.Program.Component, Version=, Culture=neutral, PublicKeyToken=abc123def456654fed321cba, processorArchitecture=MSIL">

has no effect. Trying to register my assembly on a computer that has the older version fails with the good old "Could not load file or assembly" error because it tries to find the newer version of BigCorp's .dll.

Is what I want to do even possible?

Best Solution

You can do this by referencing the older DLL directly from the project, so copy the .dll file to your project, then reference it from there.

I do this all the time with my various development projects. Typically I'll put a "References" folder inside my project to hold referenced DLL's

Related Question