使用Windows服务安装一键式应用程序时出现问题



我尝试使用InPlaceHostingManager

添加了在启动服务时安装应用程序的代码,但异常引发

System.Deployment.Application.TrustNotGrantedException:用户具有拒绝向应用程序授予所需的权限。在System.Deployment.Application.ApplicationTrust.RequestTrust(SubscriptionStatesubState,布尔isShellVisible,布尔isUpdate,ActivationContextactCtx,TrustManagerContext tmc)System.Deployment.Application.DeploymentManager.DDetermineTrustCore(布尔阻止,TrustParams tp)System.Deployment.Application.DeploymentManager.DDetermineeTrust(TrustParamstrustParams)System.Deployment.Application.InPlaceHostingManager.AssertApplicationRequirements(布尔grantApplicationTrust)System.Deployment.Application.InPlaceHostingManager.AssertApplicationRequirements()在WindowsService1.单击OnceInstaller.iphm_GetManifestCompleted(对象发送方,GetManifestCompletedEventArgs e)

从示例windows应用程序调用时,代码运行良好。

我该如何解决这个问题?

您可以尝试两种方法。

  1. 转到服务,右键单击您的服务,然后转到属性。在"登录"选项卡下,选中"允许服务与桌面交互"。

  2. 同样在"登录"选项卡下,在特定用户帐户下运行服务。

希望这能有所帮助!