ClickOnce 部署 CheckForDetailedUpdate 抛出异常

Mar*_*nas 5 .net deployment clickonce uac windows-7

我有一个 24/7 无人值守的应用程序。它通过ClickOnce部署,需要自行检查和下载更新。它会在应用程序启动时和晚上的预定时间检查更新。当它在启动时运行时,它运行得非常好。

但是,当它在预定时间执行此操作时,它会崩溃。在这两种情况下,它都使用完全相同的代码。它在 Windows 7 下运行,可能与UAC 有关系。我在想,当计算机处于空闲状态时,它可能无法访问文件系统?我真的需要解决这个问题。以下是异常详情:

信息:

服务帐户配置中不存在服务正常运行所需的权限。您可以使用服务 Microsoft 管理控制台 (MMC) 管理单元 (services.msc) 和本地安全设置 MMC 管理单元 (secpol.msc) 来查看服务配置和帐户配置。(来自 HRESULT 的异常:0x80070511)

堆栈跟踪:

at System.Deployment.Internal.Isolation.IStore.GetAssemblyInformation(UInt32 Flags, IDefinitionIdentity DefinitionIdentity, Guid& riid)
at System.Deployment.Internal.Isolation.Store.GetAssemblyManifest(UInt32 Flags, IDefinitionIdentity DefinitionIdentity)
   at System.Deployment.Application.ComponentStore.GetAssemblyManifest(DefinitionIdentity asmId)
   at System.Deployment.Application.ComponentStore.GetSubscriptionStateInternal(DefinitionIdentity subId)
   at System.Deployment.Application.SubscriptionStore.GetSubscriptionStateInternal(SubscriptionState subState)
   at System.Deployment.Application.DeploymentManager.BindCoreWithAppId(Boolean blocking, FileStream& refTransaction, String& productName)
   at System.Deployment.Application.DeploymentManager.BindCore(Boolean blocking, TempFile& tempDeploy, TempDirectory& tempAppDir, FileStream& refTransaction, String& productName)
   at System.Deployment.Application.DeploymentManager.Bind()
   at System.Deployment.Application.ApplicationDeployment.CheckForDetailedUpdate(Boolean persistUpdateCheckResult)
   at AdvancedKiosks.Utils.Updating.Updater.get_UpdateAvailabilityStatus()
   at AdvancedKiosks.Utils.Updating.Updater.get_CanUpdate()
   at AdvancedKiosks.DKMS.ViewModel.MainViewModel.<.ctor>b__6()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()
Run Code Online (Sandbox Code Playgroud)

编辑:我认为原因可能是硬盘驱动器在系统空闲一段时间后关闭。在检查更新(使用 C#)之前,有没有办法以编程方式打开硬盘驱动器?

avs*_*099 5

我将这个链接放在这里只是为了记录:链接到 MSDN 论坛。根据它,这是 ClickOnce 内部的一个错误,导致在调用 CheckForDetailedUpdate() 函数一定次数后出现此错误。