title: How to solve: At least one of the arguments for '' cannot be marshaled by the runtime marshaler
body: <p>I have a COM object written in C++ and a C# application using this ActiveX control.
  The C++ code is compiling fine, without any warnings.
  The C# application is generating several warnings like in the title.</p>
  
  <p>I see all COM functions have a similar signature, they all expect a <code>int**</code> input parameter.<br>
  I assume this is the problem. Using Google I find posts suggesting it too.  I also find posts saying I can ignore these warnings. But because I also have access to the C++ code I would like to solve it.</p>
  
  <p>This is my idl:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>[id(34), helpstring("method DrawRectangle")] HRESULT DrawRectangle([in]int** hdc, [in]float x, [in]float y, [in]int width, [in]int height, [out, retval] VARIANT_BOOL* retVal);
  </code></pre>
  
  <p>This is the C++ function:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>STDMETHODIMP CShapeDrawingOptions::DrawRectangle(int** hdc, float x, float y, int width, int height, VARIANT_BOOL* retVal)
  {
      AFX_MANAGE_STATE(AfxGetStaticModuleState())
      const auto dc = CDC::FromHandle(reinterpret_cast&lt;HDC&gt;(hdc));
  
      *retVal = this-&gt;DrawRectangleCore(dc, x, y, width, height);
      return S_OK;
  }
  </code></pre>
  
  <p>This is how I call it in C#:</p>
  
  <pre class="lang-cs prettyprint-override"><code>using(var bmp = new Bitmap(width, height, PixelFormat.Format32bppArgb))
  using (var g = Graphics.FromImage(bmp))
  {
      IntPtr hdc = g.GetHdc();
      var retVal = shapeDrawingOptions.DrawRectangle(hdc, 40.0f, 40.0f, width - 80, height - 80);
      g.ReleaseHdc(hdc);
      bmp.Save(filename, ImageFormat.Png);
  }
  </code></pre>
  
  <p><code>GetHdc</code> is returning an IntPtr which is send to the COM function and should be marshaled to <code>int**</code></p>
  
  <p>It is all working. I just want to get rid of the compiler warnings.
  The ActiveX control is distributed and other developers are getting these warnings, which is very sloppy.<br>
  I can make changes in the C++ and/or C# code.</p>