ClickOnce的充分信任的应用程序的更新与TrustNotGrantedException在Windows 8失败 [英] Clickonce full trust app update failing with TrustNotGrantedException on Windows 8

查看:1630
本文介绍了ClickOnce的充分信任的应用程序的更新与TrustNotGrantedException在Windows 8失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有它授予完全信任,并签订使用有效的证书在C#中的WinForms ClickOnce应用程序。

应用程序然而,在Windows 8机器上,它只是不能正确更新的Windows XP,Windows 7的正常运行和更新。应用程序运行正常不过。但是,第一个更新请求拉升到更高版本失败,: System.Deployment.Application.TrustNotGrantedException

在code调用 ApplicationDeployment失败后:: CheckForDetailedUpdate()失败。想知道为什么这可能发生,因为完全相同的code运行良好在所有Windows previous版本。任何帮助将AP preciated。下面是相关的堆栈跟踪:

  
    

System.Deployment.Application.TrustNotGrantedException:     用户拒绝授予所需的权限的应用程序。

         

在System.Deployment.Application.ApplicationTrust.RequestTrust(SubscriptionState子状态,布尔isShellVisible,布尔isUpdate,Activati​​onContext actCtx,TrustManagerContext TMC)

         

在System.Deployment.Application.DeploymentManager.DetermineTrustCore(布尔阻塞,TrustParams TP)

         

在System.Deployment.Application.DeploymentManager.DetermineTrust(TrustParams trustParams)

         

在System.Deployment.Application.ApplicationDeployment.CheckForDetailedUpdate(布尔persistUpdateCheckResult)

         

在System.Deployment.Application.ApplicationDeployment.CheckForDetailedUpdate()

  
解决方案

我看到这个堆栈跟踪,当我打过电话 CheckForDetailedUpdate()不设置唯一的时间手前的明确的信任。添加以下code后,更新检查工作。

  //设置的信任级别
VAR部署= ApplicationDeployment.CurrentDeployment;
VAR的appid =新ApplicationIdentity(deployment.UpdatedApplicationFullName);
VAR unrestrictedPerms =新的PermissionSet(PermissionState.Unrestricted);
VAR appTrust =新ApplicationTrust(APPID){
    DefaultGrantSet =新PolicyStatement(unrestrictedPerms)
    IsApplicationTrustedToRun = TRUE,
    坚持=真
};
ApplicationSecurityManager.UserApplicationTrusts.Add(appTrust);

// 检查更新
VAR信息= deployment.CheckForDetailedUpdate();
 

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

The application runs fine and updates correctly on Windows XP, Windows 7. However, on a Windows 8 machine, it just fails to update. The application runs correctly though. However, the first update request to move up to a later version fails with: System.Deployment.Application.TrustNotGrantedException

The code failed after the call to ApplicationDeployment::CheckForDetailedUpdate() failed. Wondering why this could happen as the exact same code is running fine on all previous versions of Windows. Any help will be appreciated. Below is the relevant 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()

解决方案

The only time I'd seen this stack trace was when I tried calling CheckForDetailedUpdate() without setting up the explicit trust before hand. After adding the code below, the update check worked.

// 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();

这篇关于ClickOnce的充分信任的应用程序的更新与TrustNotGrantedException在Windows 8失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆