title: cannot convert parameter 1 from  'cli::interior_ptr<Type>' to 'CvCapture **'
body: <p>I am capturing a video frame as follows</p>
  
  <pre><code>CvCapture *capture = cvCreateFileCapture("PATH");
  </code></pre>
  
  <p>I can read the video and process it. Everything works fine. But when I try to release the capture </p>
  
  <pre><code>cvReleaseCapture( &amp;capture ); 
  </code></pre>
  
  <p>I get </p>
  
  <pre><code>error C2664: 'cvReleaseCapture' : cannot convert parameter 1 from
   'cli::interior_ptr&lt;Type&gt;' to 'CvCapture **'
            with
            [
                Type=CvCapture *
            ]
            Cannot convert a managed type to an unmanaged type
  </code></pre>
  
  <p>The function is inside a class. </p>
  
  <pre><code>public ref class Locator
  </code></pre>
  
  <p>and I am calling it from the main </p>
  
  <p>Locator r;</p>
  
  <p>Before I added it *<em>public ref *</em> to <em>class locator</em> it was not giving me any error.</p>
  
  <p>Any ideas for fixing it? It was working fine before switching to c++-cli. </p>
  
  <p>I think it is related to some heap problem, items on the heap can be moved as a result of garbage collection. In order to send a pointer to a native method/function, you need to “pin” the pointer for the duration of the call, but I don't know how.</p>
  
  <p>Thanks.</p>
  
  <p>Updated:</p>
  
  <p>That fixed it.</p>
  
  <pre><code>pin_ptr&lt;CvCapture*&gt; p;
  p = &amp;capture;
  cvReleaseCapture( p );  
  </code></pre>