title: could not load dll or one of its dependency
body: <p>a. My C# program will load a dll (which is dynamic), for now let's take a.dll (similarly my program will load more dll like b.dll, c.dll, etc....).</p>
  
  <p>b. My program will invoke a method "Onstart" inside a.dll (it's constant for all the dll).</p>
  
  <p>I am able to achieve the above 2 cases by reflection mechanism.</p>
  
  <p>The problem is</p>
  
  <p>a. If my a.dll have any reference say xx.dll or yy.dll, then when I try to Invoke</p>
  
  <p>OnStart method of a.dll from my program. I am getting "could not load dll or one of its dependency".
  See the code snippet</p>
  
  <pre><code>Assembly assm = Assembly.LoadFrom(@"C:\Balaji\Test\a.dll");
  
  foreach (Type tp in assm.GetTypes())
  {
      if (tp.IsClass)
      {
          MethodInfo mi = tp.GetMethod("OnStart");
  
          if (mi != null)
          {
              object obj = Activator.CreateInstance(tp);
              mi.Invoke(obj,null);
              break;
          }
     }
  }
  </code></pre>
  
  <p>typically i am getting error on the line "object obj = Activator.CreateInstance(tp);" this is because a.dll has reference of xx.dll, but in my program i don't have the reference of xx.dll. Also, I cannot have the reference of xx.dll in my program because a.dll is a external assembly and can have any reference on it's own.</p>
  
  <p>Kinldy help!!!</p>