title: How do you assign the Assembly Location of an Excel VSTO Installation?
body: <p>I'm creating a Document-Level Workbook/Template written in C# and using a VSTO Installer to deploy the code.  After installing the project I have full functionality of the Spreadsheet however, when I save or copy the installed sheet to another path outside the installation folder I get the following error:</p>
  <p><img src="https://i.stack.imgur.com/bgpvg.png" alt="Uh Oh!" /></p>
  <p>With the following full details:</p>
  <pre><code>Name: 
  From: file:///C:/Users/Kronos/Desktop/ExcelTemplate1.vsto
  
  ************** Exception Text **************
  System.Deployment.Application.DeploymentDownloadException: Downloading file:///C:/Users/Kronos/Desktop/ExcelTemplate1.vsto did not succeed. ---&gt; System.Net.WebException: Could not find file 'C:\Users\Kronos\Desktop\ExcelTemplate1.vsto'. ---&gt; System.Net.WebException: Could not find file 'C:\Users\Kronos\Desktop\ExcelTemplate1.vsto'. ---&gt; System.IO.FileNotFoundException: Could not find file 'C:\Users\Kronos\Desktop\ExcelTemplate1.vsto'.
     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, Boolean checkHost)
     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)
     --- End of inner exception stack trace ---
     at System.Net.FileWebResponse..ctor(FileWebRequest request, Uri uri, FileAccess access, Boolean asyncHint)
     at System.Net.FileWebRequest.GetResponseCallback(Object state)
     --- End of inner exception stack trace ---
     at System.Net.FileWebRequest.EndGetResponse(IAsyncResult asyncResult)
     at System.Net.FileWebRequest.GetResponse()
     at System.Deployment.Application.SystemNetDownloader.DownloadSingleFile(DownloadQueueItem next)
     --- End of inner exception stack trace ---
     at Microsoft.VisualStudio.Tools.Applications.Deployment.ClickOnceAddInDeploymentManager.GetManifests(TimeSpan timeout)
     at Microsoft.VisualStudio.Tools.Applications.Deployment.ClickOnceAddInDeploymentManager.InstallAddIn()
  </code></pre>
  <p>I realize that this is due the to <code>.VSTO</code>, <code>.manifest</code> &amp; <code>.DLL</code> files not being properly referenced as the Excel spreadsheet no longer resides in the installed path.  After doing <a href="https://chat.stackexchange.com/rooms/116/conversation/kronos-koders-kodes-of-horror">some research</a> I can manually fix this by changing the copied/saved Excels <code>custom.xml</code> file within the <code>.xlsx</code> file from this:</p>
  <pre><code>name=&quot;_AssemblyLocation&quot;&gt;&lt;vt:lpwstr&gt;ExcelTemplate1.vsto|ca022788-e7c0-41d8-b8ae-2c0ba9edbbf8|vstolocal
  </code></pre>
  <p>To this:</p>
  <pre><code>name=&quot;_AssemblyLocation&quot;&gt;&lt;vt:lpwstr&gt;file://c:/&lt;path to install dir&gt;/ExcelTemplate1.vsto|ca022788-e7c0-41d8-b8ae-2c0ba9edbbf8|vstolocal
  </code></pre>
  <p>As this isn't a viable solution for my customers, how do I make the above changes using either C# code, or (more preferably) the installer?</p>
  <p><em>Note: I've tried creating a Custom Install Action (<a href="http://msdn.microsoft.com/en-us/library/ff937654.aspx" rel="nofollow noreferrer">per this MSDN Tutorial</a>) where the following is set for <code>CustomActionData</code>:</em></p>
  <pre><code>/assemblyLocation=&quot;[TARGETDIR]ExcelWorkbookProject.dll&quot;/deploymentManifestLocation=&quot;[TARGETDIR]ExcelWorkbookProject.vsto&quot;/documentLocation=&quot;[TARGETDIR]ExcelWorkbookProject.xlsx&quot;
  </code></pre>
  <p><em>to no avail.</em></p>