I'm using Embedded Mono and P/Invoke DllImport. If I have a method which
returns a string
[DllImport(__Internal, EntryPoint = CSharp_Test_ReturnString)]
public extern static string CSharp_Test_ReturnString();
The corresponding C method should strdup the string right?
extern C
{
char*
On 12.03.2012 20:51, efontana wrote:
I'm using Embedded Mono and P/Invoke DllImport. If I have a method which
returns a string
[DllImport(__Internal, EntryPoint = CSharp_Test_ReturnString)]
public extern static string CSharp_Test_ReturnString();
The corresponding C method should
On Mar 12, 2012, at 3:51 PM, efontana wrote:
I'm using Embedded Mono and P/Invoke DllImport. If I have a method which
returns a string
...
The corresponding C method should strdup the string right?
Probably not. During string marshaling, the pointer returned from
CSharp_Test_ReturnString()
Well, for Windows, I changed the code to do the following:
#ifdef WIN32
char* CSharp_Test_String()
{
string s = hello world;
int len = s.length();
char* comem = (char*)CoTaskMemAlloc(len+1);
strcpy(comem, s.c_str());
return comem;
}
#endif
Only problem is, when I print the string out from