title: can't pass C# int to unmanaged C++ DLL
body: <p>I am new to interfacing a C# .exe project to native Visual-C++ DLL.</p>
  
  <p>I can't figure out how to pass just a simple integer, and the following code results in a popup error about "PInvoke ...  unbalanced the stack".</p>
  
  <p>C++ DLL...........</p>
  
  <pre><code> extern "C"
   {
  
  __declspec(dllexport) void start_frame_generation(  int&amp; test_num )
  {
      Console::WriteLine ("test_num = " + test_num );
      }
  </code></pre>
  
  <p>C# .......................</p>
  
  <pre><code>    [DllImport("Ultrasound_Frame_Grabber.dll")]
  public static extern void start_frame_generation(  ref int test_num );
  
      private void VNGuideViewForm_Load(object sender, EventArgs e)
      {
  
              int test_num = 123;
              start_frame_generation( ref test_num);
       }
  </code></pre>