title: Passing a managed class member to a c++ method
body: <p>I have a C++ dll with the following method:</p>
  
  <pre><code>//C++ dll method (external)
  GetServerInterface(ServerInterface* ppIF /*[OUT]*/)
  {
  //The method will set ppIF
  }
  
  //ServerInterface is defined as:
  typedef void *  ServerInterface;
  </code></pre>
  
  <p>To access the dll from a C# project, I created a C++/CLI project and declared a managed class as follows:</p>
  
  <pre><code>public ref class ComWrapperManager
  {
  //
  //
  ServerInterface _serverInterface;
  void Connect();
  //
  //
  }
  </code></pre>
  
  <p>I use the Connect() method to call GetServerInterface as shown below. The first call works, the second doesn't. Can someone explain why? I need to persist that pointer as a member variable in the managed class. Any better way to do this?</p>
  
  <pre><code>    void Connect()
      {
      ServerInterface localServerInterface;
      GetServerInterface(&amp;localServerInterface); //THIS WORKS
  
      GetServerInterface(&amp;_serverInterface); //THIS DOESNT
  
      //Error 1   error C2664: 'ServerInterface ' : 
      //cannot convert parameter 1 from //'cli::interior_ptr&lt;Type&gt;' 
      //to 'ServerInterface *'
  
  
      }
  </code></pre>