Why can't I return a char* string from C++ to C# in a Release build?

后端 未结 5 894
梦如初夏
梦如初夏 2021-01-31 10:07

I\'m attempting to call the following trivial C function from C#:

SIMPLEDLL_API const char* ReturnString()
{
    return \"Returning a static string!\";
}
         


        
5条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-31 11:04

    I ran into a similar problem and specifying the "CharSet" seemed to fix it.

    [DllImport("SimpleDll", CharSet = CharSet.Ansi)]
    

    Not sure why this would be different in debug and release.

提交回复
热议问题