Clickonce WPF Windows 7 - 应用程序格式不正确。

时间:2017-03-21 20:40:21

标签: c# wpf windows-7 clickonce prerequisites

我有一台机器,干净安装了Windows 7,我想安装我的应用程序。

我在Windows 10上构建了一个WPF应用程序,其先决条件是.NET 4.5Visual C++ Redistributable Packages for Visual Studio 2013

我已将它们作为先决条件包含在我的Clickonce安装程序中:

enter image description here

enter image description here

如果我尝试在Windows 7计算机上运行从.application生成的Clickonce文件,则会收到以下错误:

  

无法继续。应用程序格式不正确。联系   应用程序供应商提供帮助。

但是,我在Windows 7计算机上运行setup.exe,它正确提示需要安装.NET 4.5Visual C++ Redistributable Packages for Visual Studio 2013。然后,它成功完成了每个先决条件的安装过程。

除非安装了先决条件,否则我会从上面收到相同的The application is improperly formatted.错误。

如果我重新运行.application文件,它将最终安装。

无论哪种方式,这绝对不是一个好的用户体验。这与在Windows 10上构建应用程序并尝试在Windows 7上安装有关吗?

我已经看到这个看似相似的问题,但我安装.NET 4.5作为先决条件:

Manifest may not be valid or the file could not be opened.

以下是错误详情:

PLATFORM VERSION INFO
    Windows             : 6.1.7601.65536 (Win32NT)
    Common Language Runtime     : 2.0.50727.5420
    System.Deployment.dll       : 2.0.50727.5420 (Win7SP1.050727-5400)
    mscorwks.dll            : 2.0.50727.5420 (Win7SP1.050727-5400)
    dfdll.dll           : 2.0.50727.4927 (NetFXspW7.050727-4900)
    dfshim.dll          : 4.0.40305.0 (Main.040305-0000)

SOURCES
    Deployment url          : file:///C:/Users/BHS/Desktop/New%20folder/BHSScaleOps.application

ERROR SUMMARY
    Below is a summary of the errors, details of these errors are listed later in the log.
    * Activation of C:\Users\BHS\Desktop\New folder\BHSScaleOps.application resulted in exception. Following failure messages were detected:
        + Exception reading manifest from file:///C:/Users/BHS/Desktop/New%20folder/BHSScaleOps.application: the manifest may not be valid or the file could not be opened.
        + Manifest XML signature is not valid.
        + SignatureDescription could not be created for the signature algorithm supplied.

COMPONENT STORE TRANSACTION FAILURE SUMMARY
    No transaction error was detected.

WARNINGS
    There were no warnings during this operation.

OPERATION PROGRESS STATUS
    * [3/21/2017 4:20:01 PM] : Activation of C:\Users\BHS\Desktop\New folder\BHSScaleOps.application has started.

ERROR DETAILS
    Following errors were detected during this operation.
    * [3/21/2017 4:20:01 PM] System.Deployment.Application.InvalidDeploymentException (ManifestParse)
        - Exception reading manifest from file:///C:/Users/BHS/Desktop/New%20folder/BHSScaleOps.application: the manifest may not be valid or the file could not be opened.
        - Source: System.Deployment
        - Stack trace:
            at System.Deployment.Application.ManifestReader.FromDocument(String localPath, ManifestType manifestType, Uri sourceUri)
            at System.Deployment.Application.DownloadManager.DownloadDeploymentManifestDirectBypass(SubscriptionStore subStore, Uri& sourceUri, TempFile& tempFile, SubscriptionState& subState, IDownloadNotification notification, DownloadOptions options, ServerInformation& serverInformation)
            at System.Deployment.Application.DownloadManager.DownloadDeploymentManifestBypass(SubscriptionStore subStore, Uri& sourceUri, TempFile& tempFile, SubscriptionState& subState, IDownloadNotification notification, DownloadOptions options)
            at System.Deployment.Application.ApplicationActivator.PerformDeploymentActivation(Uri activationUri, Boolean isShortcut, String textualSubId, String deploymentProviderUrlFromExtension, BrowserSettings browserSettings, String& errorPageUrl)
            at System.Deployment.Application.ApplicationActivator.ActivateDeploymentWorker(Object state)
        --- Inner Exception ---
        System.Deployment.Application.InvalidDeploymentException (SignatureValidation)
        - Manifest XML signature is not valid.
        - Source: System.Deployment
        - Stack trace:
            at System.Deployment.Application.Manifest.AssemblyManifest.ValidateSignature(Stream s)
            at System.Deployment.Application.ManifestReader.FromDocument(String localPath, ManifestType manifestType, Uri sourceUri)
        --- Inner Exception ---
        System.Security.Cryptography.CryptographicException
        - SignatureDescription could not be created for the signature algorithm supplied.
        - Source: System.Security
        - Stack trace:
            at System.Security.Cryptography.Xml.SignedXml.CheckSignedInfo(AsymmetricAlgorithm key)
            at System.Security.Cryptography.Xml.SignedXml.CheckSignatureReturningKey(AsymmetricAlgorithm& signingKey)
            at System.Deployment.Internal.CodeSigning.SignedCmiManifest.Verify(CmiManifestVerifyFlags verifyFlags)
            at System.Deployment.Application.Manifest.AssemblyManifest.ValidateSignature(Stream s)

COMPONENT STORE TRANSACTION DETAILS
    No transaction information is available.

1 个答案:

答案 0 :(得分:0)

您的清单使用SHA-256签名。当您尝试在仅安装了.NET 4.0的计算机上安装ClickOnce应用程序时,会收到您提到的Manifest XML signature is not valid错误,因为预计会出现.NET 4.0 SHA-1。

这就是为什么在成功安装.NET 4.5之后,一切正常。我不知道为什么这不是一步完成,而是需要两个步骤。也许这与安装新框架版本后需要重启有关吗?

解决方案是在签署清单时使用SHA-1。您可以在this answer from Miroslav Nedyalkov中找到有关如何实现此目标的信息。