c# - 在 ClickOnce Publish 上退出 list 后无法识别 .exe 文件

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

我正在使用 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)

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

最佳答案

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

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

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

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

关于c# - 在 ClickOnce Publish 上退出 list 后无法识别 .exe 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49422530/

相关文章:

c# - 在 .Net 的函数/方法中声明和处理局部变量

c# - C#中Spliterator的等价物是什么?

c# - 将相同的方法值传递给多个表单

c# - 使用 MVC5 更新 EF5 中的 Db

c# - dllimport 如何在非托管 dll 中获取哪个应用程序调用的函数

c# - 更改 DataGridView 单元格中按钮的颜色

c# - 如何根据是否可以复制来启用和禁用按钮?

c# - 跟踪多步骤任务的进度

c#-4.0 - 将项目拖出 Outlook - 记录邮件 ID

silverlight - 在 silverlight 中使用 mvvm 进行异步调用