title: Performance of the FrameworkElementAdapters class
body: <p>Can't figure why cross-domain calls is so slow for <code>FrameworkElementAdapters</code> class. Here is a simple code:</p>
  
  <pre><code>class Program
  {
      [STAThread]
      static void Main()
      {
          AppDomain domain = AppDomain.CreateDomain("AnotherDomain");
  
          var instance = (AnotherDomainClass) domain.CreateInstanceAndUnwrap(
              typeof (AnotherDomainClass).Assembly.FullName,
              typeof (AnotherDomainClass).FullName);
  
          var contract = instance.CreateContract();
      }
  }
  
  class AnotherDomainClass : MarshalByRefObject
  {
      public INativeHandleContract CreateContract()
      {
          return FrameworkElementAdapters.ViewToContractAdapter(
              new TextBlock());
      }
  }
  </code></pre>
  
  <p>The execution time of the last line <code>instance.CreateContract</code> is near <strong>1.7 sec</strong>! Where is a problem?</p>