title: 'Interface not Registered' error on ATL out-of-process callback interface
body: <p>I have an ATL in-process server that implements a callback interface like so:</p>
  
  <p><strong>.idl</strong></p>
  
  <pre><code>interface IClientEvents : IUnknown{
      [] HRESULT TestEvent(void);
  };
  
  interface IATLSimpleObject : IDispatch{
  
      [id(1)] HRESULT Advise([in] IClientEvents* clientEvents);
      [id(2)] HRESULT Unadvise(void);
  };
  </code></pre>
  
  <p><strong>.h</strong></p>
  
  <pre><code>private:
      IClientEvents* m_ClientEvents;
  public:
      STDMETHOD(Advise)(IClientEvents* clientEvents);
      STDMETHOD(Unadvise)(void);
  </code></pre>
  
  <p><strong>.cpp</strong></p>
  
  <pre><code>STDMETHODIMP CATLSimpleObject::Advise(IClientEvents* clientEvents)
  {
      m_ClientEvents = clientEvents;
      m_ClientEvents-&gt;AddRef();
  
      return S_OK;
  }
  
  STDMETHODIMP CATLSimpleObject::Unadvise(void)
  {
      m_ClientEvents-&gt;Release();
      m_ClientEvents = NULL;
  
      return S_OK;
  }
  </code></pre>
  
  <p><strong>C# client</strong></p>
  
  <pre><code>public partial class Form1 : Form, ATLProject1Lib.IClientEvents
  {
      private ATLProject1Lib.ATLSimpleObject ATLSimple = new ATLProject1Lib.ATLSimpleObject();
  
      private void Form1_Shown(object sender, EventArgs e)
      {
          ATLSimple.Advise(this);
      }
  
      private void Form1_FormClosing(object sender, FormClosingEventArgs e)
      {
          ATLSimple.Unadvise();
      }
  </code></pre>
  
  <p>It works fine, but I need to do exactly the same in an out-of-process server, however, on execution I get an 'Interface not Registered' (80040105) error when calling 'ATLSimple.Advise(this)'.</p>
  
  <p>I've spent hours searching for similar problems, but can't find anything. Any help would be greatly appreciated.</p>