title: Debug a dynamically loaded DLL
body: <p>I have a web app solution (let's say in <code>C:\WebApp</code>). At some point, I need to inject an external DLL from another solution (<code>C:\Custom</code>) and invoke a method in it.</p>
  
  <p>I'm using this code:</p>
  
  <pre><code>public ActionResult ExecuteCustomAction()
  {
      Assembly assembly = Assembly.LoadFile(@"C:\Custom\Custom\bin\Debug\Custom.dll");
      Object o = assembly.CreateInstance("Custom.Custom");
      if (o != null)
      {
          MethodInfo method = o.GetType().GetMethod("Execute");
          Object[] ob = // some params
          if (method != null)
          {
              Object returnValue = method.Invoke(o, ob).ToString();
              return new HttpStatusCodeResult(HttpStatusCode.OK);
          }
      }
      return new HttpStatusCodeResult(HttpStatusCode.InternalServerError);
  }
  </code></pre>
  
  <p>No problem until now.</p>
  
  <p>I would like to be able to debug the invoked method (the Custom solution is open in another VS instance), but didn't succeed.</p>
  
  <p>I disabled the "Just my code" option, the Debug/Windows/Modules shows that the symbols for Custom.dll are loaded correctly, I can attach both VS instances (WebApp VS and Custom VS) to the <code>w3wp</code> process, but the execution never stops on the breakpoint I put inside the <code>Execute</code> method.</p>
  
  <p>I'm not familiar with this, am I missing something obvious ?</p>
  
  <p>EDIT: The sources are built locally, I also tried copying them in the app bin folder, referencing this path instead of the original one.</p>