title: Is it possible to return a LPWSTR from C++ DLL to C# app
body: <p>The C++ function definition is this</p>
  
  <pre><code>__declspec(dllexport) LPWSTR __stdcall GetErrorString(int errCode);
  </code></pre>
  
  <p>And I call it in C# like this</p>
  
  <pre><code> [DllImport("DLLTest.dll")]
   public static extern string GetErrorString(int errCode);
  
   static void Main(string[] args)
  {
      string result = GetErrorString(5);
  }
  </code></pre>
  
  <p>I get an unhandled exception of type System.Runtime.InteropServices.SEHException</p>
  
  <p>I'm not even sure if it's ok for the C++ DLL to try to return a LPWSTR to C#...</p>
  
  <p>Thanks.</p>