title: C#: How to change search directory for dependencies of dynamically loaded assemblies within a dynamically loaded assembly?
body: <p>This is convoluted, but here goes:</p>
  
  <p>For integration with another application (in a separate directory), we are dynamically loading one of its assemblies, then using Activator to instantiate an object from that assembly.  The target assembly loads fine, but when creating an instance of the object, it attempts to dynamically load some additional dependencies and fails because it finds a newer version of them in our app dir: </p>
  
  <pre><code>var assm = Assembly.LoadFrom("full.path.to.asm"));
  var objType = assm.GetType("MyType", true);
  var obj = Activator.CreateInstance(objType);
  </code></pre>
  
  <p>The <code>assm</code> loads fine, and <code>objType</code> is obtained.  Exception occurs activating <code>obj</code> because it's dependent on an older version of an assembly (which it does have in its directory) but it's finding a newer one in our app directory first and complains about it being the wrong signature.</p>
  
  <p>I tried setting Environment.CurrentDirectory first, but it didn't make any difference.</p>