Strong Name Validation Failed Security Exception

May 2nd 2014 .NET Framework

A couple of days ago I encountered a FileLoadException with the following message:

Could not load file or assembly 'Microsoft.Web.XmlTransform, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. Strong name validation failed.

Being used to seeing similar exceptions when assemblies are missing or have their versions mismatched, it took me a while before I finally got to the bottom of it. Even more so because it was happening inside a WiX custom action, making it difficult to check the assemblies that were actually included.

The key to the solution was in carefully reading the complete message. The last sentence made it clear, that it wasn't a "common" issue of a missing assembly. There was even an inner SecurityException with the same message:

Strong name validation failed.

The next logical step was verifying the assembly strong name, using the Strong Name Tool:

PS> sn.exe -v .\Microsoft.Web.XmlTransform.dll

Microsoft (R) .NET Framework Strong Name Utility Version 4.0.30319.33440
Copyright (c) Microsoft Corporation. All rights reserved.

.\Microsoft.Web.XmlTransform.dll is a delay-signed or test-signed assembly

This made everything much clearer. Since we're talking about a third party library, I couldn't fix it myself. This was the latest version of the library at the time, therefore I had to revert back to version 1.0.0 and the problem was solved. The next step was contacting the Microsoft ASP.NET team that published the package. They responded in less than an hour and by the time of writing this post they have already published a new version and unlisted the defective one.

If you're looking for online one-on-one mentorship on a related topic, you can find me on Codementor.
If you need a team of experienced software engineers to help you with a project, contact us at Razum.
Creative Commons License