[Mono-list] Marshaling string on Windows returns Garbage??

Robert Jordan robertj at gmx.net
Tue Mar 13 12:10:54 UTC 2012


On 13.03.2012 12:48, efontana wrote:
> My code (on Windows) uses CoTaskMemAlloc to allocate the string and strcpy
> it into the buffer.
>
> However, instead of returning "test" it returns eight question marks
> "????????" usually when
> I see things like this its a ANSI / Unicode problem.  My C++ host app is not
> using Unicode.
> I tried using the CharSet=Ansi but it made no difference, on Linux I'm using
> strdup and the code
> works perfectly, any pointers?
>
> http://pastebin.com/vRBuL6A9

What does this line mean

	string s = "test";

in your C++ code? Do you mean char *s = "test"?

Have you debugged the value of "comem" just before
returning it?

Robert



More information about the Mono-list mailing list