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 C# it's garbage: (using
Trace.WriteLine)
so I'm guessing it's some sort of Unicode/ANSI thing.  I set the
CharSet=Ansi on the DllImport.

Any ideas?






--
View this message in context: 
http://mono.1490590.n4.nabble.com/Embedded-Mono-using-DllImport-Internal-and-returning-string-tp4467177p4467877.html
Sent from the Mono - General mailing list archive at Nabble.com.
_______________________________________________
Mono-list maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-list

Reply via email to