Showing posts with label validation. Show all posts
Showing posts with label validation. Show all posts

Saturday, September 14, 2013

Strong name validation failed

When we execute our code which refers an assembly(dll) then that assembly gets validated for the signature validation and if it's a non-signed or delay signed(in some cases) then it throws the error:

Could not load file or assembly '[Your file], Version=2.0.0.0, Culture=neutral, PublicKeyToken=[public key token]' or one of its dependencies. Strong name validation failed. (Exception from HRESULT: 0x8013141A).

To solve this we can disable the verification of an assembly by using sn.exe available at "C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools" (depends on the Framework you are using i.e .Net framework 4.5 in my case)

Open Command Prompt and run the command:
cd "C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools"
SN -Vr YourAssemblyName

After disabling the verification the CLR will not verify the assembly signature.

Then to re-enable the verification of the assembly run:
SN -Vu YourAssemblyName