2017-03-21 5 views
1

J'ai une machine avec une installation propre de Windows 7 où je veux installer mon application.Clickonce WPF Windows 7 - L'application est mal formatée.

J'ai construit une application WPF sur Windows 10 avec des conditions préalables de .NET 4.5 et Visual C++ Redistributable Packages for Visual Studio 2013

Je les ai inclus dans mon programme d'installation ClickOnce comme Pré-requis:

enter image description here

enter image description here

Si je tente d'exécuter le fichier .application généré à partir de Clickonce sur la machine Windows 7, je reçois le message suivant g erreur:

Cannot Continue. The application is improperly formatted. Contact the application vendor for assistance.

Cependant, je lance le setup.exe sur ma machine Windows 7, il demande à juste titre qu'il a besoin d'installer .NET 4.5 et Visual C++ Redistributable Packages for Visual Studio 2013. Il passe ensuite avec succès le processus d'installation pour chaque prérequis. Sauf que, après l'installation des prérequis, la même erreur The application is improperly formatted. s'affiche par dessus.

Si je réexécute le fichier .application, il sera finalement installé.

De toute façon, ce n'est certainement pas une bonne expérience utilisateur. Est-ce quelque chose à voir avec la construction de l'application sur Windows 10 et la tentative d'installation sur Windows 7?

Je l'ai vu cette question qui semble similaire, mais je suis l'installation de .NET 4.5 comme une condition préalable:

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

Voici les détails de l'erreur:

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. 

Répondre

0

Votre manifeste est signé en utilisant SHA-256. Lorsque vous essayez d'installer l'application ClickOnce sur une machine qui a seulement .NET 4.0 installé, vous recevez l'erreur Manifest XML signature is not valid que vous avez mentionnée car jusqu'à .NET 4.0 SHA-1 est prévu. C'est pourquoi, une fois que vous avez installé .NET 4.5 avec succès, tout fonctionne correctement. C'est ce qui explique pourquoi .NET 4.5. Je n'ai aucune idée pourquoi cela ne fonctionne pas en une seule étape, mais nécessite deux étapes à la place. Peut-être cela se rapporte à un redémarrage requis après l'installation de la nouvelle version du cadre?

La solution consiste à utiliser SHA-1 lors de la signature de votre manifeste. Vous pouvez trouver des informations sur la façon d'y parvenir en this answer from Miroslav Nedyalkov.