title: C++ COM out-of-proc marshalling data through proxy\stub
body: <p>I'm trying to create out-of-proc com server in some exe file and a client, which will access to functions through <code>proxy\stub</code> mechanism.
  I have my .idl file:</p>
  
  <pre><code>[
      object,
      uuid(eaa27f4f-ad6b-4a52-90f3-6028507751a1),
      dual,
      nonextensible,
      helpstring("IConfig Interface"),
      pointer_default(unique)
  ]
  interface IInterractionInterface : IDispatch
  {
      [id(1), helpstring("Testing function")] HRESULT Test([in] long param);
  };
  
  
  [
      uuid(6fde5037-3034-4ae1-8aa7-2ad45e5716e4),
      version(1.0),
      helpstring("Some lib")
  ]
  library SomeLib
  {
      importlib("stdole32.tlb");
      importlib("stdole2.tlb");
  
      [
          uuid(86feabe4-a0a7-45b5-bcd4-f4f7085d6b1f),
          helpstring("Some lib")
      ]
      coclass Interraction
      {
          [default] interface IInterractionInterface;
      };
  }
  </code></pre>
  
  <p>I am generated using midl compiler _p.c, _i.c files, created proxy\stub dll using .def:</p>
  
  <pre><code>LIBRARY        proxy_stub.dll
  DESCRIPTION    'generic proxy/stub DLL'
  EXPORTS        DllGetClassObject      @1 PRIVATE
                 DllCanUnloadNow        @2 PRIVATE
                 DllRegisterServer      @4 PRIVATE
                 DllUnregisterServer    @5 PRIVATE
  </code></pre>
  
  <p>Then i am registered this dll using <code>regsrv32</code>, and in win registry i have this:
  <img src="https://i.stack.imgur.com/Qf9Ll.png" alt="enter image description here"></p>
  
  <p>In my server i am created factory:</p>
  
  <pre><code>CoRegisterClassObject(CLSID_InterractionInterfaceFactory, (IClassFactory*) &amp;factory, CLSCTX_LOCAL_SERVER, REGCLS_MULTIPLEUSE, &amp;regID);
  </code></pre>
  
  <p>And it waits for client calls.
  In client i am calling my factory using CreateInstance:</p>
  
  <pre><code>result = CoGetClassObject(CLSID_InterractionInterfaceFactory, CLSCTX_LOCAL_SERVER, NULL, IID_IClassFactory, (void**)&amp;factory);
  
  if (S_OK == result)
  {
      IInterractionInterface* iface = NULL;
  
      result = factory-&gt;CreateInstance(NULL, IID_InterractionInterface, (void**)&amp;iface);
      if (S_OK == result)
      {
  
      }
  }
  </code></pre>
  
  <p>And client receives null iface and result is <code>E_UNEXPECTED</code>, but in factory it creates successfuly and i am returning S_OK from Factory::<code>CreateInstance()</code>.
  I can't understand is PS mechanism using my .dll or not? Maybe i forgot some steps? Why my object can't pass through process borders?</p>
  
  <p><strong><em>Edit:</em></strong>
  I've tried to replace the client code and now it is: </p>
  
  <pre><code>result = CoCreateInstance(CLSID_InterractionInterfaceFactory, NULL, CLSCTX_LOCAL_SERVER, IID_InterractionInterface, (void**)&amp;iface);
  iface-&gt;Test(1);
  </code></pre>
  
  <p>And when i am trying to call Test(1) it throws an error, that this is pure virtual function. And in factory in CreateInstance i am receiving requirement of Unkonown interface.</p>