title: Troubleshooting: Assembly resolution for a managed dll from a MS-Word VSTO Add-in
body: <p>I have an MS-Word VSTO Document with a code-behind dll named <code>WordDocument1.dll</code></p>
  
  <p><strong>Project folder D:\Work\Seven\WordAutomation\ContentControls\WordDocument1\bin\Debug</strong><br>
  I've copied some custom code into a <code>MyAppExecs</code> folder under that. The DLL has a private bin path specified so that code in <code>MyAppExecs</code> is reachable.</p>
  
  <p>So on startup, I load a <code>Starter.DLL</code> in the <code>MyAppExecs</code> folder which should popup a dialog, which it does. However clicking on a button on the dialog, needs to load <code>X.DLL</code>, which has unmanaged dependencies. (<code>X.DLL</code> has some managed C++, has some libs specified as additional dependencies. X is unsigned and a private assembly, not in GAC)</p>
  
  <p>X.DLL, however, cannot be resolved. From the <code>fuslogvw</code> tool, I see that it is attempting to <strong>load this DLL in the Office12 folder and failing</strong>. I have <code>ProcMon</code> running too, however, it doesn't show any unmanaged dependency file not found errors. </p>
  
  <ul>
  <li>How do I make the Word Executable see the X.Dll which is present in <code>D: \Work\Seven\WordAutomation\ContentControls\WordDocument1\bin\Debug</code>?</li>
  </ul>
  
  <p>Also, it seems strange that it can load <code>Starter.DLL</code> and a ton of others without any problems in the <code>{ProjFolder}\MyAppExecs</code> but can't see files in <code>{ProjFolder}</code>.</p>
  
  <p>Here's the <code>fuslogvw</code> output:</p>
  
  <pre><code>*** Assembly Binder Log Entry  (12/9/2008 @ 6:10:06 PM) ***
  
  The operation failed.
  Bind result: hr = 0x80070002. The system cannot find the file specified.
  
  Assembly manager loaded from:  C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll
  Running under executable  C:\Program Files\Microsoft Office\Office12\WINWORD.EXE
  --- A detailed error log follows. 
  
  === Pre-bind state information ===
  LOG: User = GEIPS-EURO\PillaiGi
  LOG: DisplayName = MyNamespace.X, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5574221fffc7dcd4
   (Fully-specified)
  LOG: Appbase = file:///C:/Program Files/Microsoft Office/Office12/
  LOG: Initial PrivatePath = NULL
  LOG: Dynamic Base = NULL
  LOG: Cache Base = NULL
  LOG: AppName = NULL
  Calling assembly : (Unknown).
  ===
  LOG: This bind starts in default load context.
  LOG: No application configuration file found.
  LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
  LOG: Post-policy reference: MyNamespace.X, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5574221fffc7dcd4
  LOG: GAC Lookup was unsuccessful.
  LOG: Attempting download of new URL file:///C:/Program Files/Microsoft Office/Office12/MyNamespace.X.DLL.
  LOG: Attempting download of new URL file:///C:/Program Files/Microsoft Office/Office12/MyNamespace.X/MyNamespace.X.DLL.
  LOG: Attempting download of new URL file:///C:/Program Files/Microsoft Office/Office12/MyNamespace.X.EXE.
  LOG: Attempting download of new URL file:///C:/Program Files/Microsoft Office/Office12/MyNamespace.X/MyNamespace.X.EXE.
  LOG: All probing URLs attempted and failed.
  </code></pre>
  
  <p><strong>Update#1</strong>: Solved the symptom but couldn't identify the cause of the problem. 
  I loaded the assembly manually via an Assembly.load. However, the above assembly resolution error kept being logged and it didn't work. 
  Finally, in a fit of desperation, I copied my word-project DLLs into <code>{ProjFolder}\MyAppExecs</code> such that all the DLLs were in one folder and it started working.</p>
  
  <p>It looks like some unmanaged dependencies of <code>X.dll</code> are not being resolved when I run from the <code>{ProjFolder}...</code> however, <code>ProcMon</code> doesn't show any sign of that. Also updated the PATH variable to include <code>{ProjFolder}\MyAppExecs</code>, but no luck.</p>
  
  <p>So copying it all into one single folder is what worked. <code>X.dll</code> is not my code so I couldn't probe any further.</p>