title: ClickOnce deployment CheckForDetailedUpdate throws an exception
body: <p>I have an application that's running 24/7 without attendance. It's deployed via <a href="http://en.wikipedia.org/wiki/ClickOnce" rel="nofollow">ClickOnce</a> and needs to check and download updates by itself. It checks for updates at application startup and at scheduled time at night. When it does it on startup, it works perfectly fine.</p>
  
  <p>However, when it does it at scheduled time, it crashes. In both cases it's using exactly the same piece of code. It's running under Windows&nbsp;7 and might have something to do with <a href="http://en.wikipedia.org/wiki/User_Account_Control" rel="nofollow">UAC</a>. I'm thinking that maybe it cannot access file system when computer is at idle state? I really need to fix that. Here are the exception details:</p>
  
  <p>Message:</p>
  
  <blockquote>
    <p>A privilege that the service requires to function properly does not
    exist in the service account configuration. You may use the Services
    Microsoft Management Console (MMC) snap-in (services.msc) and the
    Local Security Settings MMC snap-in (secpol.msc) to view the service
    configuration and the account configuration. (Exception from HRESULT:
    0x80070511)</p>
  </blockquote>
  
  <p>Stack trace:</p>
  
  <pre><code>at System.Deployment.Internal.Isolation.IStore.GetAssemblyInformation(UInt32 Flags, IDefinitionIdentity DefinitionIdentity, Guid&amp; 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&amp; refTransaction, String&amp; productName)
     at System.Deployment.Application.DeploymentManager.BindCore(Boolean blocking, TempFile&amp; tempDeploy, TempDirectory&amp; tempAppDir, FileStream&amp; refTransaction, String&amp; 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.&lt;.ctor&gt;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()
  </code></pre>
  
  <p>EDIT: I think the cause might be that the hard disk drive is turning off after some time of the system being idle. Is there a way to programatically turn on the hard disk drive before I check for updates (using C#)? </p>