Strong Name Validation Failed

2020-02-04 06:41发布

问题:

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?

回答1:

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


回答2:

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



回答3:

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)



回答4:

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.



回答5:

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.



回答6:

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.



回答7:

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.



回答8:

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.



回答9:

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



回答10:

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



回答11:

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.



回答12:

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