title: A call to PInvoke function has unbalanced the stack in debug mode
body: <p>I've started recently to work on the project that involves communication between C# and native code and thus I'm trying to understand how it works. I've loaded one of the samples from msdn, tried to launch it and I see that it works in Release mode and crashes in debug mode. Does somebody know why?</p>
  
  <pre><code>// PInvokeTest.cs
  using System;
  using System.Runtime.InteropServices;
  
  class PlatformInvokeTest
  {
      [DllImport("msvcrt.dll")]
      public static extern int puts(string c);
      [DllImport("msvcrt.dll")]
      internal static extern int _flushall();
  
      public static void Main() 
      {
          puts("Test");
          _flushall();
      }
  }
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>Additional information: A call to PInvoke function 'ConsoleApplication6!PlatformInvokeTest::puts' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.
  </code></pre>
  
  <p>This code is from following site: <a href="https://msdn.microsoft.com/en-us/library/aa288468(v=vs.71).aspx" rel="nofollow">https://msdn.microsoft.com/en-us/library/aa288468(v=vs.71).aspx</a></p>