【问题标题】:.exe file not recognized after resigning the manifest on ClickOnce Publish在 ClickOnce Publish 上退出清单后无法识别 .exe 文件
【发布时间】:2018-03-22 07:07:26
【问题描述】:

我正在使用 MVS 2015 和 .Net Framework 4.5。 我发布了我的 C# WF 应用程序,一切都很好,但我必须从应用程序文件中混淆 .exe。 在我这样做之后,很明显,安装程序不再识别 .exe,哈希值不同等等。

我使用提供必要的 .pfx 和密码的 Signtool 退出新添加的 .exe 文件,然后使用 Mage 更新 .manifest 和 .application according to the second part of this MSDN documentation

一切都成功了,但是当我运行安装程序并点击安装时,一段时间后(大约 80% 的安装进度)我收到一个错误,指出新的 .exe 文件有问题:

PLATFORM VERSION INFO
    Windows             : 10.0.16299.0 (Win32NT)
    Common Language Runtime     : 4.0.30319.42000
    System.Deployment.dll       : 4.7.2556.0 built by: NET471REL1
    clr.dll             : 4.7.2633.0 built by: NET471REL1LAST_C
    dfdll.dll           : 4.7.2556.0 built by: NET471REL1
    dfshim.dll          : 10.0.16299.15 (WinBuild.160101.0800)

SOURCES
    Deployment url          : file:///E:/share/myApp.application
    Application url         : file:///E:/share/myApp.exe.manifest

IDENTITIES
    Deployment Identity     : myApp.exe.application, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6500754c4a44ec95, processorArchitecture=msil
    Application Identity        : myApp.exe, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6500754c4a44ec95, processorArchitecture=msil, type=win32

APPLICATION SUMMARY
    * Installable application.

ERROR SUMMARY
    Below is a summary of the errors, details of these errors are listed later in the log.
    * Activation of E:\share\myApp.application resulted in exception. Following failure messages were detected:
        + Exception occurred loading manifest from file myApp.exe: the manifest may not be valid or the file could not be opened. 
        + Cannot load internal manifest from component file.

COMPONENT STORE TRANSACTION FAILURE SUMMARY
    No transaction error was detected.

WARNINGS
    There were no warnings during this operation.

OPERATION PROGRESS STATUS
    * [24.03.2018 11:03:32] : Activation of E:\share\myApp.application has started.
    * [24.03.2018 11:03:32] : Processing of deployment manifest has successfully completed.
    * [24.03.2018 11:03:32] : Installation of the application has started.
    * [24.03.2018 11:03:33] : Processing of application manifest has successfully completed.
    * [24.03.2018 11:03:35] : Found compatible runtime version 4.0.30319.
    * [24.03.2018 11:03:35] : Request of trust and detection of platform is complete.

ERROR DETAILS
    Following errors were detected during this operation.
    * [24.03.2018 11:03:43] System.Deployment.Application.InvalidDeploymentException (ManifestLoad)
        - Exception occurred loading manifest from file myApp.exe: the manifest may not be valid or the file could not be opened. 
        - Source: System.Deployment
        - Stack trace:
            at System.Deployment.Application.Manifest.AssemblyManifest.ManifestLoadExceptionHelper(Exception exception, String filePath)
            at System.Deployment.Application.Manifest.AssemblyManifest.LoadFromInternalManifestFile(String filePath)
            at System.Deployment.Application.DownloadManager.ProcessDownloadedFile(Object sender, DownloadEventArgs e)
            at System.Deployment.Application.FileDownloader.DownloadModifiedEventHandler.Invoke(Object sender, DownloadEventArgs e)
            at System.Deployment.Application.FileDownloader.OnModified()
            at System.Deployment.Application.SystemNetDownloader.DownloadSingleFile(DownloadQueueItem next)
            at System.Deployment.Application.SystemNetDownloader.DownloadAllFiles()
            at System.Deployment.Application.FileDownloader.Download(SubscriptionState subState, X509Certificate2 clientCertificate)
            at System.Deployment.Application.DownloadManager.DownloadDependencies(SubscriptionState subState, AssemblyManifest deployManifest, AssemblyManifest appManifest, Uri sourceUriBase, String targetDirectory, String group, IDownloadNotification notification, DownloadOptions options)
            at System.Deployment.Application.ApplicationActivator.DownloadApplication(SubscriptionState subState, ActivationDescription actDesc, Int64 transactionId, TempDirectory& downloadTemp)
            at System.Deployment.Application.ApplicationActivator.InstallApplication(SubscriptionState& subState, ActivationDescription actDesc)
            at System.Deployment.Application.ApplicationActivator.PerformDeploymentActivation(Uri activationUri, Boolean isShortcut, String textualSubId, String deploymentProviderUrlFromExtension, BrowserSettings browserSettings, String& errorPageUrl, Uri& deploymentUri)
            at System.Deployment.Application.ApplicationActivator.PerformDeploymentActivationWithRetry(Uri activationUri, Boolean isShortcut, String textualSubId, String deploymentProviderUrlFromExtension, BrowserSettings browserSettings, String& errorPageUrl)

我做错了什么?我错过了什么? :(

【问题讨论】:

    标签: c# winforms c#-4.0 visual-studio-2015 clickonce


    【解决方案1】:

    我已经调查了 Marko 应用程序,如果您在使用 .NET Refactor 并且遇到上面的问题,这里是让它工作的解决方法:

    无论如何,如果您要在发布后修改程序集,则无论如何都需要重新计算哈希。怎么可能:

    1. 不要使用 Visual Studio 发布引擎并生成你 应用程序“mage.exe”。它让你准备好你的资源 应用程序,然后创建 ClickOnce 应用程序。
    2. 从第二个下载链接[here] 下载实用程序。执行并[选择]您的文件夹>将操作更改为[更新]>和[构建]。无需更多操作。更新操作将重新计算哈希值。
    3. 如果您的混淆器软件支持命令行参数,那么您可以在 .exe VS 项目属性中添加“构建后事件”脚本,它将在单击构建之前执行。

    您可以在此处找到“部署混淆程序集”文章:Securing ClickOnce Applications

    【讨论】:

    • 我会尽快查看您的教程并返回结果。谢谢你的时间,谢尔盖!
    • 我想我没听懂你说的话。我会更清楚地告诉你:我发布了项目(setup.exe、.application 文件和 Application Files 文件夹存在),我用我的新文件更改了 myApp.exe 文件。我正在使用带有 UPDATE 选项的工具,但它显示“SourcePath 应用程序文件名不等于 DeploymentUrl 文件名”。当我点击构建时。但话又说回来,我不确定我是否需要 UPDATE,我尝试了 RESIGN 选项,但是当我运行设置时,它说清单已损坏。
    • 在我使用您的工具退出应用程序后,安装它时收到的错误与主线程中出现的错误相同。 :(
    • 是的,谢谢,我做到了,发布者最终获取了混淆的 .exe,但是,当我从该发布者部署运行设置时,它显示帖子中的初始错误。 :)) 我简直不敢相信!这很累人,但再次感谢您的参与,谢尔盖!如果我能做到这一点,我会带着答案回来! :D
    • 没问题 :) 我认为您有一些不典型的行为,如果您的应用程序不是私有的,请给我您的 ClickOnce 文件夹以供测试,或者如果它已在某处发布,请在 xyliman[A] 上告诉我邮箱这对我来说很有趣。谢谢
    猜你喜欢
    • 1970-01-01
    • 2022-07-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-12
    相关资源
    最近更新 更多