views:

52

answers:

2

Is dll versioning implemented differently in .NET 1.1 versus .NET 3.5? It seems I can mix and match older and new versions of dependent dll's in deployed applications using .NET 1.1 but leads to problems when doing the same mixing a matching with dll's running in deployed .NET 3.5 applications.

+1  A: 

A lot of this is dictated based on the "useSpecificVersion" property that can be set on your reference. The general rule of thumb is that you can use a NEWER version of a referenced DLL, just not an older version.

If you have "UseSpecificVersion" set to true, it will force the application to use that version, and ONLY that version of the referenced DLL. This is a feature that has been in .NET all along.

Use Specific Version Example

If you build dll X with a reference to version 01.01.00.00 of Referenced assembly Y. Any use with a version other than 01.01.00.00 of assembly Y will result in a failure.

Standard Example

If you build a dll X with a reference to version 01.01.00.00 of Referenced assembly Y, you can use version 01.01.00.00 or later without issue.

  • 01.01.00.00 - Works
  • 01.01.01.00 - Works
  • 01.05.00.00 - Works
  • 01.00.01.00 - Fails, as it is a previous version.
Mitchel Sellers
Can you elaborate more on the "useSpecificVersion"? Is this property supported in .NET 1.1? If not that would probably explain the difference in what seems to be going on.
Achilles
Does that help?
Mitchel Sellers
It does. Thanks for the help.
Achilles
So how does the newer version dll work in a deployed application where one of it's dependencies is an older version than the one it was compiled against?
Achilles
If it was compiled against version 1.0, and you put version 0.9 in the directory it will fail. As in my last example above.
Mitchel Sellers
A: 

I don’t think it has really changed, but you can read about it in MSDN.

You cannot mix and match older and new versions because the older ones are going to be a problem.

Say you have:

abc.exe 1.0, that has references to XYZ.DLL and ZZZ.DLL both 1.0 as well.

If you recompile ZZZ.DLL and make it 1.1, abc.exe should continue to work and will load the DLL if it’s present in it’s load path.

However, if you copy ZZZ.DLL v0.9, abc.exe will fail to load that dll, because it’s older.

Bear in mind that if XYZ.DLL also has references to ZZZ.DLL, then the same rules apply.

On the other hand, you can always install the DLLS in the GAC and have different versions available. That way, when you load the assembly, if it’s in the GAC, .NET will try to find the “correct one”, but will fall back to whatever it can use, provided it’s a higher version.

Martín Marconcini