title: intermittent failure with clickonce deployment (0x8007001F)
body: <p>I am deploying an WPF application in business environment (AD) using clickonce deployment. The application is develop with Visual Studio 2013 and based on .Net 4.5. The deployment targets Windows 7 machines only. The deployment Server uses IIS 7.5 and runs on Windows Server 2008 R2.</p>
  
  <p>The deployment is configured that the applications checks for updates before the applications starts.</p>
  
  <p>The deployment works at least the most of the time but I recently experiencing random issues on a few machines while installing an application update.</p>
  
  <p>The user receives the following error message:</p>
  
  <blockquote>
    <p>Application cannot be started. Contact the application publisher. </p>
    
    <p>Cannot start the application. Contact the application vendor for assistance.</p>
  </blockquote>
  
  <p>this error is document in <a href="http://msdn.microsoft.com/en-us/library/ms229001.aspx" rel="nofollow">MSDN, Troubleshooting Specific Errors in ClickOnce Deployments</a></p>
  
  <blockquote>
    <p>These are generic error messages that occur when the application
    cannot be started, and no other specific reason can be found.</p>
  </blockquote>
  
  <p>I managed to gather a log file which covers this error:</p>
  
  <pre><code>PLATFORM VERSION INFO
  Windows                       : 6.1.7601.65536 (Win32NT)
  Common Language Runtime       : 4.0.30319.18444
  System.Deployment.dll         : 4.0.30319.18408 built by: FX451RTMGREL
  clr.dll                       : 4.0.30319.18444 built by: FX451RTMGDR
  dfdll.dll                     : 4.0.30319.18408 built by: FX451RTMGREL
  dfshim.dll                    : 4.0.41209.0 (Main.041209-0000)
  
  SOURCES
      Deployment url: file:///C:/Users/ADUSERNAME/AppData/Roaming/Microsoft/Windows/Start%20Menu/Programs/Supply%20Chain%20Services%20-%20Systems%20and%20Processes/APPLICATIONNAME/APPLICATIONNAME%20Suite.appref-ms%7C
      Server: Microsoft-IIS/7.5
      X-Powered-By: ASP.NET
      Deployment Provider url: http://SERVERNAME:PORT/APPLICATIONNAME.application
      Application url: http://SERVERNAME:PORT/Application%20Files/APPLICATIONNAME_1_0_3_9/APPLICATIONNAME.exe.manifest
      Server: Microsoft-IIS/7.5
      X-Powered-By: ASP.NET
  
  IDENTITIES
      Application Identity: APPLICATIONNAME.exe, Version=1.0.3.9, Culture=neutral, PublicKeyToken=XXXXXXXXXXXXXXXX, processorArchitecture=msil, type=win32
  
  ERROR SUMMARY
      Below is a summary of the errors, details of these errors are listed later in the log.
      * Activation of C:\Users\ADUSERNAME\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Supply Chain Services - Systems and Processes\APPLICATIONNAME\APPLICATIONNAME Suite.appref-ms| resulted in exception. Following failure messages were detected:
                      + A device attached to the system is not functioning. (Exception from HRESULT: 0x8007001F)
  
  COMPONENT STORE TRANSACTION FAILURE SUMMARY
      No transaction error was detected.
  
  WARNINGS
      There were no warnings during this operation.
  
  OPERATION PROGRESS STATUS
      * [08/09/2014 09:25:02] : Activation of C:\Users\ADUSERNAME\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Supply Chain Services - Systems and Processes\APPLICATIONNAME\APPLICATIONNAME Suite.appref-ms| has started.
      * [08/09/2014 09:25:04] : Performing necessary update check as specified by the deployment.
      * [08/09/2014 09:25:07] : Consuming new update.
      * [08/09/2014 09:25:09] : Installation of the application has started.
      * [08/09/2014 09:25:10] : Processing of application manifest has successfully completed.
      * [08/09/2014 09:25:10] : Found compatible runtime version 4.0.30319.
      * [08/09/2014 09:25:10] : Request of trust and detection of platform is complete.
      * [08/09/2014 09:25:18] : Downloading of subscription dependencies is complete.
      * [08/09/2014 09:25:18] : Commit of the downloaded application has started.
  
  ERROR DETAILS
      Following errors were detected during this operation.
      * [08/09/2014 09:25:22] System.Runtime.InteropServices.COMException
                      - A device attached to the system is not functioning. (Exception from HRESULT: 0x8007001F)
                      - Source: System.Deployment
                      - Stack trace:
                                      at System.Deployment.Internal.Isolation.IStore.Transact(IntPtr cOperation, StoreTransactionOperation[] rgOperations, UInt32[] rgDispositions, Int32[] rgResults)
                                      at System.Deployment.Application.ComponentStore.SubmitStoreTransaction(StoreTransactionContext storeTxn, SubscriptionState subState)
                                      at System.Deployment.Application.ComponentStore.CommitApplication(SubscriptionState subState, CommitApplicationParams commitParams)
                                      at System.Deployment.Application.SubscriptionStore.CommitApplication(SubscriptionState&amp; subState, CommitApplicationParams commitParams)
                                      at System.Deployment.Application.ApplicationActivator.InstallApplication(SubscriptionState&amp; subState, ActivationDescription actDesc)
                                      at System.Deployment.Application.ApplicationActivator.ConsumeUpdatedDeployment(SubscriptionState&amp; subState, ActivationDescription actDesc)
                                      at System.Deployment.Application.ApplicationActivator.PerformDeploymentUpdate(SubscriptionState&amp; subState, String&amp; errorPageUrl)
                                      at System.Deployment.Application.ApplicationActivator.ProcessOrFollowShortcut(String shortcutFile, String&amp; errorPageUrl, TempFile&amp; deployFile)
                                      at System.Deployment.Application.ApplicationActivator.PerformDeploymentActivation(Uri activationUri, Boolean isShortcut, String textualSubId, String deploymentProviderUrlFromExtension, BrowserSettings browserSettings, String&amp; errorPageUrl)
                                      at System.Deployment.Application.ApplicationActivator.ActivateDeploymentWorker(Object state)
  
  COMPONENT STORE TRANSACTION DETAILS
      * Transaction at [08/09/2014 09:25:22]
                      + System.Deployment.Internal.Isolation.StoreOperationStageComponent
                                      - Status: Installed
                                      - HRESULT: 0x0
                                      - Manifest: ZJHPL38T.V57.application
                      + System.Deployment.Internal.Isolation.StoreOperationSetDeploymentMetadata
                                      - Status: Set
                                      - HRESULT: 0x0
                      + System.Deployment.Internal.Isolation.StoreOperationStageComponent
                                      - Status: Installed
                                      - HRESULT: 0x0
                                      - Manifest: APPLICATIONNAME.exe.manifest
                      + System.Deployment.Internal.Isolation.StoreOperationStageComponentFile
                                      - Status: Installed
                                      - HRESULT: 0x0
                                      - File: APPLICATIONNAME.exe.config
                      !!! Removed 550 Lines !!!
                      + System.Deployment.Internal.Isolation.StoreOperationInstallDeployment
                                      - Status: Installed
                                      - HRESULT: 0x0
                                      - AppId: http://SERVERNAME:PORT/APPLICATIONNAME.application#APPLICATIONNAME.application, Version=1.0.3.9, Culture=neutral, PublicKeyToken=e5b020d18338a5ca, processorArchitecture=msil
                      + System.Deployment.Internal.Isolation.StoreOperationSetDeploymentMetadata
                                      - Status: Set
                                      - HRESULT: 0x0
                      + System.Deployment.Internal.Isolation.StoreOperationUninstallDeployment
                                      - Status: Uninstalled
                                      - HRESULT: 0x0
                                      - AppId: http://SERVERNAME:PORT/APPLICATIONNAME.application#APPLICATIONNAME.application, Version=1.0.3.3, Culture=neutral, PublicKeyToken=e5b020d18338a5ca, processorArchitecture=msil
                      + System.Deployment.Internal.Isolation.StoreOperationSetDeploymentMetadata
                                      - Status: Set
                                      - HRESULT: 0x0
                      + System.Deployment.Internal.Isolation.StoreTransactionOperationType (27)
                                      - HRESULT: 0x8007001f
  </code></pre>
  
  <p>I also activated detailed logging (<a href="https://robindotnet.wordpress.com/2010/05/31/enhanced-logging-in-clickonce-deployment/" rel="nofollow">using this guide</a>) for my test machine but I was not able to reproduce this error or recognize a pattern which causes the error.</p>
  
  <p>The error affects <em>only</em> 5% to 10% percent of the users, uninstall &amp; reinstall is a workaround but not a solution.</p>
  
  <hr>
  
  <p>In Reply to <strong>Hans Passant:</strong></p>
  
  <p>The | is indeed a strange character, I have neither clue where it comes from nor what it stands for in this context. However the deployment url (including the | symbol) is always the same and it works in 90% of the cases. I don’t think that the | symbol is the cause of the problem. However, I will try to find out why the character is there and come back to you afterwards.</p>
  
  <p>Uninstall/Reinstall solves the problem on client side (Same installer!). Therefore we can exclude a corrupted .Net/VS install.</p>
  
  <p>Anti-malware (McAfee) could be a problem I will investigate as soon I manage to reproduce the error on one of my test machines.</p>
  
  <p>The file path is 123 characters long; the file name has 21 characters. File path + file name = 144 characters</p>