Avoid Partial Binds

A partial bind is when only part of the assembly display name is given when loading an assembly.

Assembly.LoadWithPartialName() also uses partial binding. First, it calls Assembly.Load(). But, if that fails to find the assembly, it will return the latest version of that assembly available in the GAC.

But, avoid using any form of partial binding – it’s the cause of Dll Hell:

  • May Be Backwards-Incompatible
    What if you want version 1, but you get version 50, which is totally incompatible with the one you wanted? Apps get broken by getting the latest version, even if you get supposedly ‘compatible’ version 2. If there’s any change at all, there’s a risk of breaking compatibility.
  • May Be Forwards-Incompatible
    What if you built with version 50, but get version 1 (since that’s the only one available) - are all of your assemblies really going to be forwards-compatible? If so, that means that you aren't allowed to add any new features - ever!
  • Can't Safely Install Other Apps
    Installing one app can break another app calling LoadWithPartialName() by installing a newer, incompatible version of a shared assembly.
  • Breaks Assemblies Dependent On Others
    Say that A requires a certain version of B. But, you mix-and-match by loading one version of A and an incompatible version of B. Not only does that risk strange new failures, but it also risks opening up a new security hole which the makers of A didn't expect.

For these reasons, LoadWithPartialName() has been deprecated in v2 - use Assembly.Load() instead. I vote that it's better to fail with a good error message than to automatically use another version of an assembly. It will make a lot more sense to the user and should be easy to remedy (while failing in weird, unpredicted ways will just confuse the user and make them think that you write buggy code).