Please do not reply to this email- if you want to comment on the bug, go to the URL shown below and enter your comments there.
Changed by [EMAIL PROTECTED] http://bugzilla.ximian.com/show_bug.cgi?id=80426 --- shadow/80426 2007-01-02 11:34:43.000000000 -0500 +++ shadow/80426.tmp.6016 2007-01-02 11:34:43.000000000 -0500 @@ -0,0 +1,62 @@ +Bug#: 80426 +Product: Mono: Class Libraries +Version: 1.2 +OS: +OS Details: RHEL kernel 2.6.9-42 on i686 +Status: NEW +Resolution: +Severity: +Priority: Wishlist +Component: System +AssignedTo: [EMAIL PROTECTED] +ReportedBy: [EMAIL PROTECTED] +QAContact: [EMAIL PROTECTED] +TargetMilestone: --- +URL: +Cc: +Summary: Problem with interop and wide strings (narrow strings are ok) + +Please fill in this template when reporting a bug, unless you know what you +are doing. +Description of Problem: +I have a C++ shared lib that exports a function with this declaration: + + extern "C" __attribute__((stdcall)) void foo(const char* myParam); + +and I have a C# program compiled with gmcs which declares it like this: + + [DllImport("myLib.so", CallingConvention=CallingConvention.StdCall)] + public static extern void foo([MarshalAs(UnmanagedType.LPStr)] String +myParam); + +If I invoke the foo function in C# with the string "Hello" it works +properly and the bytes that get sent to the C++ function are +0x48,0x65,0x6c,0x6c,0x6f,0x00 as expected. + +However, if I change the MarshalAs type to UnmanagedType.LPWStr and change +the C++ dll to accept a wchar_t* instead of a char*, the bytes do not come +across properly - the bytes still arrive the same as if the mono were +sending a narrow string. Also, if I add to the DllImport attributes +'CharSet=CharSet.Unicode' that doesn't make a difference either, the +strings are still comming through as the same narrow strings. + + +Steps to reproduce the problem: +1. See above. Simple invoke an exported C++ shared lib function using wide +strings +2. +3. + +Actual Results: + Bytes are always passed to the C++ lib as narrow strings regardless of +the attributes listed in C# + +Expected Results: + Bytes are passed to the C++ lib as wide strings or narrow strings as per +the DllImport attributes + +How often does this happen? + Each time + + +Additional Information: _______________________________________________ mono-bugs maillist - [email protected] http://lists.ximian.com/mailman/listinfo/mono-bugs
