Ron Jacobs

Windows Workflow Foundation

Assembly.Load, Version Numbers and Unsigned Assemblies

Assembly.Load, Version Numbers and Unsigned Assemblies

  • Comments 1

Never assume anything, test everything

All these years I assumed that Assembly.Load() would respect version numbers if specified in the FullName string.   As I’ve been adding more test coverage to Microsoft.Activities I found that Assembly.Load does not work that way.

Suppose you have an assembly named ActivityLibrary and you deploy V1 but you try to load V2

// This call will succeed and happily load V1 if it finds ActivityLibrary.dll
Assembly.Load("ActivityLibrary, Version=, Culture=neutral, PublicKeyToken=null");

To force Assembly.Load to respect the version number you must sign the assembly

// Try to load V2 this call will fail if it cannot find V2
Assembly.Load("ActivityLibrary, Version=, Culture=neutral, PublicKeyToken=824701d2ab05d638");

So be careful out there and sign your assemblies.

  • Hehe. Quite a shock huh. I think the rationale used to be that unsigned assemblies can be bin edited in any way you see fit (including version) so you could trust what you find there anyway ...

Page 1 of 1 (1 items)