title: How to get interface to C# object wrapped in COM, from MFC DLL
body: <p>I have C# object in a DLL.
  I call a method of this object via COM from MFC DLL. like this:</p>
  
  <pre><code>BOOL CForwarder::InitMyManagedFlex()
  {
      // Initialize COM.
      HRESULT hr = CoInitialize(NULL);
  
      // Create the interface pointer.
      IForwarderPtr pIFwd(__uuidof(MyForwarder));
  
      long lResult = 0;
      VARIANT_BOOL ret = FALSE;
      BSTR bstr = AsciiToBSTR("AAA");
  
      // Call the Add method.
      pIFwd-&gt;Start(bstr, &amp;ret);
  
      SysFreeString(bstr);
  
      wprintf(L"The result is %d\n", ret);
  
      // Uninitialize COM.
      CoUninitialize();
  
      return (ret == VARIANT_TRUE) ? TRUE : FALSE;
  }
  </code></pre>
  
  <p>Then after a while I call another method SetTimeFormat in exactly the same manner.
  The problem is that every time I call in this manner I instantiate a new C# object, but in fact I am trying to reach the same object that was created the first time and simply set one of its properties to a different value.</p>
  
  <p>The problem seems to be in this line:</p>
  
  <pre><code>IForwarderPtr pIFwd(__uuidof(MyForwarder));
  </code></pre>
  
  <p>So how do I get the interface to the same C# object instead of creating a new one?</p>