Passing C string reference to C#
Posted
by user336109
on Stack Overflow
See other posts from Stack Overflow
or by user336109
Published on 2010-05-08T10:33:54Z
Indexed on
2010/05/08
10:38 UTC
Read the original article
Hit count: 138
c#
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.
© Stack Overflow or respective owner