在 VSTO Word 插件中调试 TrustNotGrantedException
我收到针对 VSTO 单词插件的某些特定用户抛出的 TrustNotGrantedException 异常。
这些用户已正确安装证书。
当应用程序检查更新时抛出异常:
try
{
ApplicationDeployment.CurrentDeployment.CheckForUpdate()
}
catch(TrustNotGrantedException ex)
{
Log(ex);
}
堆栈跟踪记录如下:
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.CheckForUpdate() at iReport.iReportAddIn.CheckForUpdates()
是否有人经历过这种情况或知道如何在代码中或使用任何解决方法来防止这种情况?
编辑:
我已阅读此关于这些问题的博客文章,看起来这可能是问题用户的 CAS 权限问题。
我将尝试让有问题的用户使用此方法访问更新 URL,并稍后进行跟进,尽管我更希望能够在代码中阻止这种情况,而不是修复单个客户端计算机。类似于:
caspol -m -ag 1 -url "http://machinename/application/*" FullTrust -exclusive on
Edit2:
使用 caspol.exe 有效!有谁知道如何防止代码中发生这种情况? 或者谁能解释为什么它只会发生在选定的用户身上?
Edit3:
我将尝试添加
<system.web>
<!-- level="[Full|High|Medium|Low|Minimal]" -->
<trust level="Full" originUrl=""/>
</system.web>
到 app.config
Edit4:
将完整的 CAS 信任添加到 app.config 没有帮助。谁能告诉我是否有可能实现 CASPOL 在代码中所做的事情?
Edit5:
如果无法在代码中执行此操作,是否有一种简单的方法可以在 clickonce 安装过程中运行 CASPOL 命令?
I'm getting TrustNotGrantedException thrown for some specific users of our VSTO word addin.
These users have the certificate installed correctly.
The exception is being thrown when the app checks for updates:
try
{
ApplicationDeployment.CurrentDeployment.CheckForUpdate()
}
catch(TrustNotGrantedException ex)
{
Log(ex);
}
The stack trace is logged as follows:
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.CheckForUpdate() at iReport.iReportAddIn.CheckForUpdates()
Has anyone experienced this or knows how to prevent this in the code or with any workarounds?
Edit:
I have read through this blog post on the issues and it seems like it could be an issue with CAS Permissions for the problem users.
I'll try and give a problem user access to the update URL using this and will follow up in a bit, although I would much prefer to be able to prevent this in the code instead of fixing individual client machines. Something like:
caspol -m -ag 1 -url "http://machinename/application/*" FullTrust -exclusive on
Edit2:
Using caspol.exe worked! Does anyone know a way to prevent this from happening in the code?
Or can anyone explain why it could only be happening to select users?
Edit3:
I'm going to try add
<system.web>
<!-- level="[Full|High|Medium|Low|Minimal]" -->
<trust level="Full" originUrl=""/>
</system.web>
to the app.config
Edit4:
Adding full CAS trust to the app.config didn't help. Can anyone show me if its possible to achieve what CASPOL is doing in code?
Edit5:
If it isn't possible to do this in code, is there a easy way to run the CASPOL command as part of the clickonce install?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在最新版本的 Windows 中,下载的文件被标记为被阻止,并对其施加安全限制,当其他应用程序使用沙盒时,可能会导致损坏。
该实现使用
NTFS 备用流
。如果文件被阻止,您可以通过右键单击该文件、查看属性并查看取消阻止
按钮来判断。单击取消阻止将删除流
并释放额外的安全限制。也可以使用 sysinternals 删除它
streams.exe< /代码>
。通过在 Windows 7 计算机上下载插件来测试这是否是您的问题,然后在不解锁的情况下进行安装,看看是否会重现该问题。
In recent versions of Windows, downloaded files are flagged as blocked and have security restrictions imposed on them that can cause breakage when consumed by other apps due to the sandboxing.
The implementation uses
NTFS alternate streams
. If the file is blocked you can tell by right clicking on the file, viewing properties and seeing theunblock
button. Clicking unblock removes thestream
and releases the extra security restrictions.It can also be removed using
sysinternals
streams.exe
. Test whether this is your issue by downloading your plugin on a Windows 7 machine, and then install without unblocking to see if it reproduces the issue.