Passing C string reference to C#
- by user336109
c code
extern "C" __declspec(dllexport) int export(LPCTSTR inputFile, string &msg)
{
msg = "haha"
}
c# code
[DllImport("libXmlEncDll.dll")]
public static extern int XmlDecrypt(StringBuilder inputFile, ref Stringbuilder newMsg)
}
I got an error when I try to retrieve the content of newMsg saying that I'm trying to write to a protected memory area.
What is the best way to retrieve the string from c to c#. Thanks.