Thursday, June 3, 2010

Delay signed assembly problem

If you are using delay signing feature in Visual Studio, to defer the signing of your assemblies. You quickly run into problems trying to reference them during development.  Delay signing is used when the private key is closely guarded and developers do not have access to it.  Only the public key is available to partially sign the assemblies.  The final signing of the assemblies with the matching private key is done usually during the build process.

When you reference a compiled binary that is only partially signed during development (you would not do this outside of a developer environment), you will get an exception as follows:

FileLoadException as unhandled.
Could not load file or assembly 'AssemblyAbc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b4571042c8aa084e' or one of its dependencies. Strong name validation failed. (Exception from HRESULT: 0x8013141A)

To enable this reference in Development, you can skip the certificate verification process using the Sn.exe tool.
sn.exe -Vr *,b4571042c8aa084e

Run that command in the Visual Studio 2010 Command Line and thereafter the reference will work.
The Vr option signifies you wish to skip verification for this assembly. * signifies any user, and the hex value is the public key token of the partially signed assembly.

If you're running a 64-bit installation of Vista you'll need to use the sn.exe located at C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\x64\sn.exe

No comments:

Post a Comment