Complete Clickonce Application Application Update with TrustNotGrantedException on Windows 8

We have a clickonce winforms application in C # that is given full trust and signed using a valid certificate.

The application works fine and correctly updates in Windows XP, Windows 7. However, on a computer with Windows 8, it simply does not update. The application is working correctly, though. However, the first update request to upgrade to a later version is not executed: System.Deployment.Application.TrustNotGrantedException

The code failed after the call to ApplicationDeployment::CheckForDetailedUpdate() failed. I wonder why this can happen, since exactly the same code works fine in all previous versions of Windows. Any help would be appreciated. The following is the appropriate stack trace:

 System.Deployment.Application.TrustNotGrantedException: User has refused to grant required permissions to the application. at System.Deployment.Application.ApplicationTrust.RequestTrust(SubscriptionState subState, Boolean isShellVisible, Boolean isUpdate, ActivationContext actCtx, TrustManagerContext tmc) at System.Deployment.Application.DeploymentManager.DetermineTrustCore(Boolean blocking, TrustParams tp) at System.Deployment.Application.DeploymentManager.DetermineTrust(TrustParams trustParams) at System.Deployment.Application.ApplicationDeployment.CheckForDetailedUpdate(Boolean persistUpdateCheckResult) at System.Deployment.Application.ApplicationDeployment.CheckForDetailedUpdate() 
+8
c # visual-studio winforms clickonce
source share
3 answers

The only time I saw this stack trace was when I tried to call CheckForDetailedUpdate() without setting up explicit trust before hand. After adding the code below, the update check was checked.

 // Setup the trust level var deployment = ApplicationDeployment.CurrentDeployment; var appId = new ApplicationIdentity(deployment.UpdatedApplicationFullName); var unrestrictedPerms = new PermissionSet(PermissionState.Unrestricted); var appTrust = new ApplicationTrust(appId) { DefaultGrantSet = new PolicyStatement(unrestrictedPerms), IsApplicationTrustedToRun = true, Persist = true }; ApplicationSecurityManager.UserApplicationTrusts.Add(appTrust); // Check for update var info = deployment.CheckForDetailedUpdate(); 
+6
source share

There are two reasons for this MSDN page . But it seems that a TrustNotGrantedException usually occurs when you deploy a new ClickOnce update that uses more privileges than the previous version ...

  • The application uses permission, and the user rejects the request for increased trust; or
  • The application uses trusted application deployments, and the digital certificate used to sign the application is not listed as a trusted publisher on the local computer. If you deployed an update for an application and the update uses more permissions than the previous version, and ClickOnce throws a TrustNotGrantedException, the new version will not install .

Thus, it makes sense that it will not be able to update, since the security level of applications has changed since the last installation, so they will need to reinstall it.

0
source share

We had the same problem, and we ended up using the InPlaceHostingManager class. This is done to install or upgrade your ClickOnce deployment. GetManifestAsync() fires the GetManifestCompleted event, which gives you the version number. You can then call DownloadApplicationAsync() and handle the DownloadApplicationCompleted event. So far this works, and a TrustNotGrantedException is not thrown.

0
source share

All Articles