The C++ function definition is this
__declspec(dllexport) LPWSTR __stdcall GetErrorString(int errCode);
And I call it in C# like this
See the accepted answer here: PInvoke for C function that returns char *
The short version: you must marshal the return value as an IntPtr or the .NET runtime makes some assumptions and tries to delete the memory pointed to by the char pointer. This can cause crashes if the assumptions that the runtime makes are wrong.