[Mono-list] Embedded Mono using DllImport(__Internal) and returning string

2012-03-12 Thread efontana
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*

Re: [Mono-list] Embedded Mono using DllImport(__Internal) and returning string

2012-03-12 Thread Robert Jordan
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

Re: [Mono-list] Embedded Mono using DllImport(__Internal) and returning string

2012-03-12 Thread Jonathan Pryor
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()

Re: [Mono-list] Embedded Mono using DllImport(__Internal) and returning string

2012-03-12 Thread efontana
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