Я пытаюсь передать строку из C # в C DLL. Из того, что я прочитал, .NET должен выполнить преобразование из строки в char * для меня, однако я получаю «ошибка CS1503: Аргумент '1': невозможно преобразовать из 'string' в 'char *'» Может кто-нибудь посоветовать мне, где я ошибся? Спасибо.
Код C #
[DllImport("Source.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
public static unsafe extern bool StreamReceiveInitialise(char* filepath);
const string test = "test";
// This method that will be called when the thread is started
public void Stream()
{
if (StreamReceiveInitialise(test))
{
}
}
C DLL
extern "C"
{
__declspec(dllexport) bool __cdecl StreamReceiveInitialise(char* filepath);
}