title: Loading Mixed-Mode C++/CLI .dll (and dependencies) dynamically from unmanaged c++
body: <p>I have a managed C++ assembly I'm loading dynamically in an unmanaged c++ application through a standard LoadLibrary() call. The managed C++ assembly has dependencies on several more managed (C#) assemblies. Everything worked fine until I moved all the managed assemblies to a subdirectory of the unmananged application. To illustrate:</p>
  
  <ul>
  <li><p>Managed C++ .dll (MyCoolDll.dll)</p>
  
  <ul>
  <li>Dependent on DotNetDll1.dll</li>
  <li>Dependent on DotNetDll2.dll</li>
  </ul></li>
  <li><p>Unmanaged C++ app (MyCoolApp.exe)</p>
  
  <ul>
  <li>Loads MyCoolDll.dll via LoadLibrary("MyCoolDll.dll")</li>
  </ul></li>
  </ul>
  
  <p>This worked fine, until I moved MyCoolDll.dll, DotNetDll1.dll &amp; DotNetDll2.dll to /someSubDirectory (the code in MyCoolApp.exe was updated to LoadLibrary("someSubDirectory/MyCooldll.dll")</p>
  
  <p>I'm guessing when MyCoolDll.dll is loaded, it's trying to find DotNetDll1.dll and DotNetDll2.dll in the working directory, instead of the directory it lives in.</p>
  
  <p>How can I tell MyCoolDll.dll its dependencies live in a subdirectory? It's a library running inside of an unmanaged app, so I don't think I can specify this in an app.config or anything?</p>