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?

12条回答
Explosion°爆炸
2楼-- · 2020-02-04 07:25

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楼-- · 2020-02-04 07:27

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.

查看更多
女痞
4楼-- · 2020-02-04 07:31

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楼-- · 2020-02-04 07:33

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

查看更多
孤傲高冷的网名
6楼-- · 2020-02-04 07:40

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楼-- · 2020-02-04 07:40

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.

查看更多
登录 后发表回答