title: ClickOnce setup.exe fails, but the .application file works fine when using a Windows share for deployment
body: <p>I am getting the error of <code>System.Deployment.Application.DeploymentDownloadException</code> when I try to run setup.exe for my ClickOnce application. If run it over the network from its original location it works fine, but if I copy <code>setup.exe</code> from the path on the server I get the error</p>
  
  <blockquote>
    <p>Can not download application. The Application is missing required files.</p>
  </blockquote>
  
  <p>I need the setup as it installs some prerequisites (<a href="http://en.wikipedia.org/wiki/.NET_Framework" rel="nofollow noreferrer">.NET</a> 4) that the end user may not have.</p>
  
  <p>Clicking the details button from the error window gives the following information:</p>
  
  <pre><code>PLATFORM VERSION INFO
      Windows             : 6.1.7601.65536 (Win32NT)
      Common Language Runtime     : 4.0.30319.237
      System.Deployment.dll       : 4.0.30319.1 (RTMRel.030319-0100)
      clr.dll             : 4.0.30319.237 (RTMGDR.030319-2300)
      dfdll.dll           : 4.0.30319.1 (RTMRel.030319-0100)
      dfshim.dll          : 4.0.31106.0 (Main.031106-0000)
  
  SOURCES
      Deployment url          : file:///C:/Users/srchamberlain/Downloads/ContractFlowTool.application
  
  ERROR SUMMARY
      Below is a summary of the errors, details of these errors are listed later in the log.
      * Activation of C:\Users\srchamberlain\Downloads\ContractFlowTool.application resulted in exception. Following failure messages were detected:
          + Downloading file:///C:/Users/srchamberlain/Downloads/ContractFlowTool.application did not succeed.
          + Could not find file 'C:\Users\srchamberlain\Downloads\ContractFlowTool.application'.
          + Could not find file 'C:\Users\srchamberlain\Downloads\ContractFlowTool.application'.
          + Could not find file 'C:\Users\srchamberlain\Downloads\ContractFlowTool.application'.
  
  COMPONENT STORE TRANSACTION FAILURE SUMMARY
      No transaction error was detected.
  
  WARNINGS
      There were no warnings during this operation.
  
  OPERATION PROGRESS STATUS
      * [8/16/2011 12:23:26 PM] : Activation of C:\Users\srchamberlain\Downloads\ContractFlowTool.application has started.
  
  ERROR DETAILS
      Following errors were detected during this operation.
      * [8/16/2011 12:23:26 PM] System.Deployment.Application.DeploymentDownloadException (Unknown subtype)
          - Downloading file:///C:/Users/srchamberlain/Downloads/ContractFlowTool.application did not succeed.
          - Source: System.Deployment
          - Stack trace:
              at System.Deployment.Application.SystemNetDownloader.DownloadSingleFile(DownloadQueueItem next)
              at System.Deployment.Application.SystemNetDownloader.DownloadAllFiles()
              at System.Deployment.Application.FileDownloader.Download(SubscriptionState subState)
              at System.Deployment.Application.DownloadManager.DownloadManifestAsRawFile(Uri&amp; sourceUri, String targetPath, IDownloadNotification notification, DownloadOptions options, ServerInformation&amp; serverInformation)
              at System.Deployment.Application.DownloadManager.DownloadDeploymentManifestDirectBypass(SubscriptionStore subStore, Uri&amp; sourceUri, TempFile&amp; tempFile, SubscriptionState&amp; subState, IDownloadNotification notification, DownloadOptions options, ServerInformation&amp; serverInformation)
              at System.Deployment.Application.DownloadManager.DownloadDeploymentManifestBypass(SubscriptionStore subStore, Uri&amp; sourceUri, TempFile&amp; tempFile, SubscriptionState&amp; subState, IDownloadNotification notification, DownloadOptions options)
              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)
          --- Inner Exception ---
          System.Net.WebException
          - Could not find file 'C:\Users\srchamberlain\Downloads\ContractFlowTool.application'.
          - Source: System
          - Stack trace:
              at System.Net.FileWebRequest.EndGetResponse(IAsyncResult asyncResult)
              at System.Net.FileWebRequest.GetResponse()
              at System.Deployment.Application.SystemNetDownloader.DownloadSingleFile(DownloadQueueItem next)
          --- Inner Exception ---
          System.Net.WebException
          - Could not find file 'C:\Users\srchamberlain\Downloads\ContractFlowTool.application'.
          - Source: System
          - Stack trace:
              at System.Net.FileWebResponse..ctor(FileWebRequest request, Uri uri, FileAccess access, Boolean asyncHint)
              at System.Net.FileWebRequest.GetResponseCallback(Object state)
          --- Inner Exception ---
          System.IO.FileNotFoundException
          - Could not find file 'C:\Users\srchamberlain\Downloads\ContractFlowTool.application'.
          - Source: mscorlib
          - Stack trace:
              at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
              at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath)
              at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
              at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync)
              at System.Net.FileWebStream..ctor(FileWebRequest request, String path, FileMode mode, FileAccess access, FileShare sharing, Int32 length, Boolean async)
              at System.Net.FileWebResponse..ctor(FileWebRequest request, Uri uri, FileAccess access, Boolean asyncHint)
  
  COMPONENT STORE TRANSACTION DETAILS
      No transaction information is available.
  </code></pre>
  
  <p>The root of the problem is it is trying to download its files from the same path as <code>setup.exe</code> is run from (<code>file:///C:/Users/srchamberlain/Downloads</code> in this case) instead of the actual deployment <a href="http://en.wikipedia.org/wiki/Uniform_Resource_Locator" rel="nofollow noreferrer">URL</a> (<code>\\fs1\contractflowtool</code>)</p>
  
  <p>I have seen a <a href="https://stackoverflow.com/questions/972212/clickonce-nightmare-system-deployment-application-deploymentdownloadexception">few</a> <a href="http://blogs.msdn.com/b/gauravb/archive/2008/10/31/clickonce-publish-on-iis-fails-with-system-deployment-application-deploymentdownloadexception-unknown-subtype.aspx" rel="nofollow noreferrer">solutions</a>, but all of them tell me the solution is to change the <a href="http://en.wikipedia.org/wiki/MIME" rel="nofollow noreferrer">MIME</a> type on IIS. <strong>IIS is not installed on the server that is hosting the files.</strong></p>
  
  <p>What else can be done to fix this besides "change the MIME types"?</p>
  
  <hr>
  
  <p>UPDATE</p>
  
  <p>See the second post in <a href="http://social.msdn.microsoft.com/Forums/ar/winformssetup/thread/2886403f-090e-4fa9-82b0-c4f2c26de649" rel="nofollow noreferrer">this thread</a> for some test cases I ran. The summary is: it appears that the <code>setup.exe</code> file uses the working directory to download its files as it works fine when I run the EXE file over the network, however it fails if I copy the EXE to my local disk.</p>
  
  <p>How do I resolve this issue other than "Tell people to just run it from the network path"?</p>
  
  <hr>
  
  <p>UPDATE2:
  Looking at the <code>setup.exe</code> file with a hex editor, I could not find my install path anywhere in it. When I changed the install path to <a href="http://example.com/Test" rel="nofollow noreferrer">http://example.com/Test</a> I was able to find it easily.</p>
  
  <p>Is it a Visual Studio bug that it does not save the publishing location/install path if you are using a <a href="http://en.wikipedia.org/wiki/Path_%28computing%29#Uniform_Naming_Convention" rel="nofollow noreferrer">UNC</a> path?</p>