title: C#, DLL import API not working properly in VS2012 .NET Framework 4.5
body: <p>I have an issue with my WinForms project which was created in VS2005 .NET Framework 2.0, which I just upgraded to VS2012 .NET Framework 4.5. In my project, I used a third-party DLL by <code>DllImport</code> and used its functions as I had all documentation for them. </p>
  
  <p>The problem is one of the functions in the imported DLL which works fine in VS2005 .NET Framework 2.0 is not working in VS2012 .NET 4.5.</p>
  
  <p>Following are my code snippets from my project:</p>
  
  <pre><code>[DllImport("W5EditLD.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "K5GetClassName")]
  public static extern string GetClassName();//Dll import definition
  
  public string _GetClassName()
  {
      return GetClassName();//wrapper function to DLL import function 
  }
  
  string sClassName = _GetClassName();//where i call API via wrapper method,**
  </code></pre>
  
  <p>Above code snippet works fine in VS2005 .NET Framework 2.0
  But when I upgraded my project to VS2012 .NET Framework 4.5 I have to do it in the following way:</p>
  
  <pre><code>[DllImport("W5EditLD.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "K5GetClassName")]
  
  public static extern IntPtr GetClassName();//Dll import definition
  
  public IntPtr _GetClassName()
  {
      return GetClassName();//wrapper function to DLL import function 
  }
  
  IntPtr ptr = _GetClassName();//where i call API via wrapper method,    
  string sClassName = System.Runtime.InteropServices.Marshal. PtrToStringAnsi(ptr);
  </code></pre>
  
  <p>Why this is? Is automatic string marshalling not supported in VS2012 .NET Framework 4.5?</p>