title: MS Office Word VSTO “Load On Demand”
body: <p>We have developed a product that is a standard VSTO addin (Word 2010 and Word 2013, x86 only).  By default when it is installed, it is installed for all users (ie. the addin registry entries are inserted into HKLM - <code>HKEY_LOCAL_MACHINE\SOFTWARE\[Wow6432Node]\Microsoft\Office\Word\Addins</code>).  </p>
  
  <p>When the value for the <code>LoadBehavior</code> reg key is set to <code>0x3</code> (i.e. "Load at Startup"), the addin works perfectly fine, however when we set the value for <code>LoadBehavior</code> to <code>0x10</code> (i.e. "Load on demand"), the addin does not work as we would expect:  </p>
  
  <p>Due to UAC (and that Word does not run elevated), the value of <code>LoadBehavior</code> in HKLM is not changed from <code>0x10</code> to <code>0x9</code> but instead is overridden by creating a <code>LoadBehavior</code> key (with value <code>0x9</code>) in the HKCU hive. </p>
  
  <p>Unfortunately, we have found that this HKCU overridden value is not taken into account <strong>unless the Manifest key is present in the HKCU hive along with <code>LoadBehavior</code>)</strong>. More info on this related thread: <a href="https://social.msdn.microsoft.com/Forums/vstudio/en-US/3776734b-333e-423b-9c08-7c7a441c3e94/load-behavior-and-word-addin?forum=vsto" rel="nofollow noreferrer">https://social.msdn.microsoft.com/Forums/vstudio/en-US/3776734b-333e-423b-9c08-7c7a441c3e94/load-behavior-and-word-addin?forum=vsto</a></p>
  
  <p>The 'obvious' remedy for this issue is to write the <code>Manifest</code> into HKCU for each user (as well as in HKLM) at install time <strong>OR</strong> when each user run the addin the first time. There are however some serious drawbacks with this approach:</p>
  
  <ul>
  <li>Uninstalling the addin requires removing every user HKCU values to prevent users experiencing loading issues (this is not recommended and poses other issues/complications such as the need to use Active Setup - <a href="https://stackoverflow.com/questions/13516684/remove-registry-keys-under-hkcu-on-a-per-machine-installation">Remove registry keys under HKCU on a per machine installation</a>).</li>
  <li>Users which have these values in their (roaming) HKCU hive, experience issues when they login to a machine in the same domain which does not have our addin installed.</li>
  </ul>
  
  <p><strong>Is it a bug that the manifest is not obtained from HKLM</strong> where the <code>LoadBehavior</code> is set appropriately in HKCU? I think this issue would be resolved if the <code>LoadBehavior</code> in HKLM could be overridden in HKCU without the need for the <code>Manifest</code> value to be overridden as well.</p>
  
  <p>Anyone knows of a way to overcome this issue?</p>