ExecutionEngineException: String conversion error: Illegal byte sequence encounted in the input.

When I try to import c++ dll in unity on win10, I got an error:
ExecutionEngineException: String conversion error: Illegal byte sequence encounted in the input.
Why? And I have tried the unity stable version 2019 and 2021.

c++:

const char* say_hello(const char* text) {
    std::string s = "Hello, " + std::string(text);
    return s.c_str();
}

c#:

[DllImport(libraryName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
public static extern IntPtr say_hello([MarshalAs(UnmanagedType.LPStr)] string text);

Debug.Log(Marshal.PtrToStringAnsi(say_hello("world")));

Hey gqy2468! This sub-forum is for Netcode for Entities package queries. I’m not sure exactly where you should post your support question (probably here: Unity Engine - Unity Discussions).