Strong Name Validation Failed

27

Two machines. Both with .NET 3.5 and the VS 2008 VC++ SP1 redistributables

A single exe which uses two signed DLLs, one in C++/CLI and one in C#

The exe loads and runs fine on one machine.

On the other, I get "Strong Name Validation Failed" on the C++ executable (HRESULT 0x8013141A)

Any ideas?

c#
c++-cli
code-signing
asked on Stack Overflow Dec 31, 2008 by (unknown user)

12 Answers

37

Open the command prompt as administrator and enter following commands:

reg DELETE "HKLM\Software\Microsoft\StrongName\Verification" /f
reg ADD "HKLM\Software\Microsoft\StrongName\Verification\*,*" /f
reg DELETE "HKLM\Software\Wow6432Node\Microsoft\StrongName\Verification" /f
reg ADD "HKLM\Software\Wow6432Node\Microsoft\StrongName\Verification\*,*" /f
answered on Stack Overflow Dec 7, 2015 by Butsaty • edited Dec 7, 2015 by Tunaki
17

Open the command prompt as administrator and enter the following command:

"C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\x64\sn.exe" -Vr <dllpath>

Pay attention that the argument are case sensitive. Source with more details: http://blogs.msdn.com/b/keithmg/archive/2012/03/20/strong-name-validation-failed-exception-from-hresult-0x8013141a.aspx

answered on Stack Overflow Sep 12, 2013 by Adam Szabo
14

You must use the 64-bit version of sn.exe on a 64-bit machine. (C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\x64\sn.exe)

answered on Stack Overflow Oct 20, 2011 by DoctorFoo
7

Is the one the code runs on a "development" machine where you might have run "sn.exe -Vr AssemblyName.dll" at some stage which would allow you to use a delay signed assembly as if it were fully signed. When you transfer the delay signed assembly to another machine and run it, it will fail strong name validation because it is not fully signed.

answered on Stack Overflow Apr 24, 2009 by Colin Desmond
6

In my case, I had the same issue with Visual Studio 2015 and I already had signed the assembly.

I fixed it by this way: Right click on the project which causes the issue -> "Properties" -> "Build" -> Change the value of the "Platform target" field.

I had to change it from Any CPU to x86 but I guess that in function of the project and the library which is failing, you should change its value to x64.

answered on Stack Overflow Apr 5, 2016 by christiansr85
4

The SN.EXE is Missing in Newer versions of Visual Studio. In Visual studio 2012, we must use "Developer command prompt for Visual studio 2012". Then Run the command "sn".

Syntax: sn -Vr *,2d58152b8e842be2

where "2d58152b8e842be2" is the public key token shown in the Error message. Somehow this alone did not solve my problem.

answered on Stack Overflow Jan 14, 2015 by Vishnu Prasanth
3

You might be able to bypass this on development by going into the project settings -> Signing -> and unchecking "Sign the assembly".

I ran into this today while debugging against a source code copy of the Entity Framework.

answered on Stack Overflow Nov 15, 2013 by jocull
3

If someone can't find 64-bit version of sn.exe, check here: C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.7.2 Tools\x64\sn.exe

answered on Stack Overflow Oct 7, 2019 by Adrian
2

I encountered this today and stumbled across http://timgeerts.blogspot.co.uk/2009/08/strong-name-validation-failed.html, which seems to be the solution.

Option 1) Turn off code coverage (in VS 2010, go to Test Settings -› Data and Diagnostics -› Untick the "Enabled" box next to Code Coverage).

Option 2) Add the signing key file to the code coverage configuration (in VS 2010, go to Test Settings -› Data and Diagnostics -› select Code Coverage and click on "Configure" at the top. This corresponds to the "keyFile" attribute for the CodeCoverage tag in the .testsettings file.)

In VS 2012, code coverage is enabled by default. It can be disabled through a .runsettings file with an appropriate exclusion. See http://msdn.microsoft.com/en-us/library/jj159530.aspx for more information and a sample file. For option 2, although there doesn't seem to be an explicit setting available in the .runsettings file, the right thing seems to happen automatically with regard to signing (YMMV). However, if you're referencing a VS 2010 .testsettings file then it will need editing as above.

answered on Stack Overflow Feb 27, 2014 by jo.p.kennedy
2

Right-click on Project → Properties → Build tab → Platform Target → Select "x64"

answered on Stack Overflow Sep 13, 2017 by Ayslan • edited Sep 13, 2017 by Cody Gray
0

I am working with VS.Net Ultimate 2012

and this solution helped me:

Right click on Project-> properties-> Build Tab-> switch Generate serialization assembly to off-> done

answered on Stack Overflow Nov 26, 2014 by Fery
0

I fixed this by going to the Build menu (top pane) and say "Rebuild xxxProject.plugin" for that specific project only, contrary to building the entire solution.

answered on Stack Overflow May 8, 2017 by ToFo

User contributions licensed under CC BY-SA 3.0