title: Options for executing API functions in a new AppDomain
body: <p>I want to call an API running inside a new AppDomain (FWIW in the asp.net MVC framework).  I discovered a few options for executing code within the AppDomain.  I'm not happy with the verbosity of the solutions I've seen thus far:</p>
  
  <p>I discovered:</p>
  
  <p><strong>assembly execution</strong>:</p>
  
  <pre><code>appDomain.ExecuteAssembly("SOMEPATH.exe");
  </code></pre>
  
  <p>Firing off an executeable is not a good way to make API calls.  I imagine the need to pass various parameters to <code>Main()</code> that represent each public method in the API.</p>
  
  <p><strong>Reflection:</strong></p>
  
  <pre><code>ObjectHandle handle = appDomain.CreateInstance("someassembly.dll", "someType");
  A a = (A) handle.Unwrap();
  a.SomeField = "foo";
  </code></pre>
  
  <p>This strikes me as a superior solution for an API.  However, I'm not a big fan of Reflection due to the complex setup and the potential for performance overhead.  </p>
  
  <p>Is there a means to loadup an appdomain in a new thread so I can fire off methods without going through these hoops?  In other words some means to effectively:</p>
  
  <pre><code>Thread.Start("useThisAppdomain", 
    //do work.
    className.M();//run in new appdomain
  );
  </code></pre>
  
  <p>or the like?</p>