views:

88

answers:

2

I have a .NET project which references a DLL called ABCPDF. The version number used when the application was written is 7.0.2.3 and the application was deployed onto a staging server.

The version of the software on the staging server is 7.0.2.8 and the application is breaking saying that it cannot find version 7.0.2.3

Surely it should use the 7.0.2.8 version of the DLL rather than require me to recompile using 7.0.2.8 on my development machine? If I were to update the version of ABCPDF on live servers 6 months later it would break every application using a previous version without me knowing.

Am I getting the wrong end of the stick here?

A: 

Right click on the reference and click Properties.

In the properties for the reference, set "Specific Version" to false.

While this could cause issues if ABCPDF broke backwards compatibility, if they didn't this will solve your problem.

Edit: Does not apply if you're using signed assemblies, see other answer. Was unaware ABCPDF was signed.

Aequitarum Custos
Is this set to true by default? Seems crazy that the default functionality would be to guarantee your application breaks if you do a software update on the servers running it!
Craig Bovis
-1: The "Specific Version" flag only affects compilation, not runtime reference resolution. You need to use binding redirection or a related technique to allow newer versions of strong-named assemblies to take the place of the version you compiled against. See the MSDN article "Redirecting Assembly Verisons" (http://msdn.microsoft.com/en-us/library/7wd6ex19.aspx) for full information.
bdukes
Using the specific version tip didn't work. @bdukes is that the only way? It seems absolutely mad that you need to update every application on a server to support the new version!
Craig Bovis
@Craig you can set the `bindingRedirect` in the machine's config, rather than for each application's config.
bdukes
+2  A: 

You may consider using assembly binding redirection, see the below code:

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
            <assemblyIdentity name="Your.Assembly" publicKeyToken="your token here"/>
            <bindingRedirect oldVersion="7.0.2.3" newVersion="7.0.2.8"/>
        </dependentAssembly>
    </assemblyBinding>
</runtime>

Just put that code fragment in your App.Config file

Igor Korkhov