强名称验证失败
两台机器。 均带有 .NET 3.5 和 VS 2008 VC++ SP1 可再发行组件
单个 exe 使用两个签名 DLL,一个在 C++/CLI 中,一个在 C# 中
该 exe 在一台计算机上加载并运行良好。
另一方面,我在 C++ 可执行文件上收到“强名称验证失败”(HRESULT 0x8013141A)
有什么想法吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(12)
以管理员身份打开命令提示符并输入以下命令:
Open the command prompt as administrator and enter following commands:
以管理员身份打开命令提示符并输入以下命令:
请注意参数区分大小写。
包含更多详细信息的来源:http://blogs.msdn.com/b/keithmg/archive/2012/03/20/strong-name-validation-failed-exception-from-hresult-0x8013141a.aspx
Open the command prompt as administrator and enter the following command:
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
您必须在 64 位计算机上使用 64 位版本的 sn.exe。 (C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\x64\sn.exe)
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)
代码是在“开发”机器上运行的,您可能在某个阶段运行了“sn.exe -Vr AssemblyName.dll”,这将允许您使用延迟签名的程序集,就好像它已完全签名一样。 当您将延迟签名的程序集传输到另一台计算机并运行它时,它将失败强名称验证,因为它未完全签名。
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.
就我而言,我在使用
Visual Studio 2015
时遇到了同样的问题,并且我已经签署了程序集。我通过以下方式修复了它: 右键单击导致问题的项目 -> “属性”-> “构建”-> 更改“平台目标”字段的值。
我必须将其从
Any CPU
更改为x86
但我猜想在项目功能和如果库失败,您应该将其值更改为 x64。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
tox86
but I guess that in function of the project and the library which is failing, you should change its value tox64
.如果有人找不到 64 位版本的
sn.exe
,请在此处检查:C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.7.2 Tools\x64\sn.exe
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
您也许可以通过进入项目设置 -> 来绕过开发过程中的此问题。 签约-> 并取消选中“签署程序集”。
我今天在针对实体框架的源代码副本进行调试时遇到了这个问题。
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.
较新版本的 Visual Studio 中缺少 SN.EXE。 在视觉工作室 2012 中,
我们必须使用“Visual studio 2012 的开发人员命令提示符”。 然后运行命令“sn”。
语法: sn -Vr *,2d58152b8e842be2
其中“2d58152b8e842be2”是错误消息中显示的公钥令牌。 不知何故,仅此一点并没有解决我的问题。
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.
我今天遇到了这个问题,并偶然发现了 http://timgeerts。 blogspot.co.uk/2009/08/strong-name-validation-failed.html,这似乎是解决方案。
选项 1) 关闭代码覆盖率(在 VS 2010 中,转到测试设置 -> 数据和诊断 -> 取消选中代码覆盖率旁边的“启用”框)。
选项 2)将签名密钥文件添加到代码覆盖率配置中(在 VS 2010 中,转到“测试设置”->“数据和诊断”->选择“代码覆盖率”,然后单击顶部的“配置”。这对应于“keyFile”属性对于 .testsettings 文件中的 CodeCoverage 标记。)
在 VS 2012 中,默认情况下启用代码覆盖率。 可以通过带有适当排除的 .runsettings 文件来禁用它。 请参阅http://msdn.microsoft.com/en-us/library/jj159530。 aspx 了解更多信息和示例文件。 对于选项 2,尽管 .runsettings 文件中似乎没有可用的显式设置,但关于签名 (YMMV) 似乎会自动发生正确的事情。 但是,如果您引用 VS 2010 .testsettings 文件,则需要如上所述进行编辑。
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.
右键单击项目→属性→构建选项卡→平台目标→选择“x64”
Right-click on Project → Properties → Build tab → Platform Target → Select "x64"
我正在使用 VS.Net Ultimate 2012
,这个解决方案帮助了我:
右键单击项目-> 属性-> 构建选项卡-> 将生成序列化程序集切换为关闭-> 完毕
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
我通过转到“构建”菜单(顶部窗格)并仅针对该特定项目说“重建 xxxProject.plugin”来解决此问题,这与构建整个解决方案相反。
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.