.net Clickonce 签名的应用程序失败,并显示“具有与清单中指定的不同的计算哈希值”。法师无法解决问题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22487515/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Clickonce signed application fails with "has a different computed hash than specified in manifest". Mage fails to resolve issue
提问by TheFIXGuy
I've been really struggling with this one for days. I've seen other posts like ClickOnce Deployment Error: different computed hash than specified in manifest, but the solutions do not seem to work for me.
几天来我一直在为这个而苦苦挣扎。我看过其他帖子,例如ClickOnce 部署错误:不同的计算散列与 manifest 中指定的不同,但这些解决方案似乎对我不起作用。
I have a valid code signing certificate, and have been using it to sign my ClickOnce application for months. I realized I wasn't signing the executable and dlls themselves, so I attempt to do so. Now every time I publish and run the setup.exe, it fails with: "File, xxxxxx.dll, has a different computed hash than specified in manifest."
我有一个有效的代码签名证书,并且几个月来一直使用它来签署我的 ClickOnce 应用程序。我意识到我没有签署可执行文件和 dll 本身,所以我尝试这样做。现在,每次我发布并运行 setup.exe 时,它都会失败并显示:“文件 xxxxxx.dll 的计算哈希值与清单中指定的不同。”
If I do not sign the exe and Dlls, I can redeploy. I made sure all copies of the exe/dlls are signed in all directories (Target, Obj) before publishing. I've tried using Mage/MageUI but have had no success. Is it possible to configure a ClickOnce install without signed code, then publish signed code? Seems logical, but perhaps I am missing something.
如果我不签署 exe 和 Dlls,我可以重新部署。在发布之前,我确保 exe/dll 的所有副本都在所有目录(Target、Obj)中签名。我试过使用 Mage/MageUI 但没有成功。是否可以在没有签名代码的情况下配置 ClickOnce 安装,然后发布签名代码?似乎合乎逻辑,但也许我错过了一些东西。
Thanks, Gregg
谢谢,格雷格
采纳答案by Charles
Is there any chance you are trying to deploy a WPF application and using Visual Studio 2012 or later? If so, you have to use the "AfterCompile" setting in your project file to sign the application, or you end up with the hash mismatch.
您是否有机会尝试部署 WPF 应用程序并使用 Visual Studio 2012 或更高版本?如果是这样,您必须使用项目文件中的“AfterCompile”设置来签署应用程序,否则最终会出现哈希不匹配。
See this stackoverflow post: SignTool Not Signing ClickOnce App Using SHA256, Only Uses SHA1
请参阅此 stackoverflow 帖子: SignTool Not Signing ClickOnce App Using SHA256, Only Uses SHA1
Which links to Robin's excellent blog solution: http://robindotnet.wordpress.com/2013/04/14/windows-8-and-clickonce-the-definitive-answer-revisited/
Robin 优秀博客解决方案的链接:http: //robindotnet.wordpress.com/2013/04/14/windows-8-and-clickonce-the-definitive-answer-revisited/
回答by Graham Laight
First thing to check: Publish - Updates - Application Updates - URL is correct (e.g. you have a test URL and a deployment URL)
首先要检查:发布 - 更新 - 应用程序更新 - URL 是否正确(例如,您有一个测试 URL 和一个部署 URL)
Second thing to check: remove System.Deployment reference and add it back in. We had the problem after moving project from VS2012 to VS2015, and this action got it working again after hours of trying different ideas.
要检查的第二件事:删除 System.Deployment 引用并将其重新添加。将项目从 VS2012 移至 VS2015 后,我们遇到了问题,经过数小时尝试不同的想法后,此操作使其再次工作。
btw - here's an easy guide to how to do the accepted answer:
顺便说一句 - 这是一个如何做公认答案的简单指南:
right click the project and select "Unload Project"
right click the project and select "Edit"
add the following before the final project close tag:
右键单击项目并选择“卸载项目”
右键单击项目并选择“编辑”
在最终项目结束标记之前添加以下内容:
<Target Name="AfterCompile" Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Exec Command=""C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Bin\signtool.exe" sign /f "C:\temp\myPFX.pfx" /p "admin" /v "$(ProjectDir)obj$(ConfigurationName)$(TargetFileName)"" />
</Target>
change the location of signtool.exe and pfx (signature) file to your own locations
save the project file
reload the project
将 signtool.exe 和 pfx(签名)文件的位置更改为您自己的位置
保存项目文件
重新加载项目
回答by joelMendoza
I'm still using Visual Studio 2015, app config transformation per build configuration, TFS and using different release branches. After much research, I was not able to find a solution to fix this issue until I started using the publish wizard button.
我仍在使用 Visual Studio 2015、每个构建配置的应用程序配置转换、TFS 并使用不同的发布分支。经过大量研究,直到我开始使用发布向导按钮,我才能找到解决此问题的解决方案。
If you are using VS2015, first try publishing with the "Publish Wizard..." button instead of the "Publish Now" button. Apparently, the publish wizard button updates the manifest file after the app config transformation has occurred.
如果您使用的是 VS2015,请先尝试使用“发布向导...”按钮而不是“立即发布”按钮进行发布。显然,发布向导按钮会在应用配置转换发生后更新清单文件。
回答by ZahidKakar
My Problem resolved after I clean DebugFolder of my Application and then also Remove Everything from Publishfolder on the server (target machine). Cleaning Publishfodler doesn't stop your application working installed on clients machines. So follow the instruction and that already worked for me after 3 days searching. Then I Re-Publish the Application and it start working and they clients side application also updated.
在我清理应用程序的调试文件夹,然后从服务器(目标机器)上的发布文件夹中删除所有内容后,我的问题解决了。Cleaning Publishfodler 不会阻止您的应用程序安装在客户端机器上。所以按照说明进行操作,经过 3 天的搜索,这已经对我有用了。然后我重新发布应用程序,它开始工作,他们的客户端应用程序也更新了。
回答by Rembunator
Many of my problems with clickonce and code-signing using Visual Studio 2013, including this particular problem, were resolved by installing vs2013 update 4.
通过安装 vs2013 更新 4,我在使用 Visual Studio 2013 单击一次和代码签名时遇到的许多问题(包括这个特定问题)都得到了解决。
(maybe update 3 would have been enough but I installed update 4 after several days of frustration)
(也许更新 3 就足够了,但经过几天的挫折后我安装了更新 4)
I am using signtool with the /sha1 option in the post-build event of every assembly. (run always).
我在每个程序集的构建后事件中使用带有 /sha1 选项的 signtool。(始终运行)。

