Prev: Sync DB between Windows Mobile and MySQL - manually ?
Next: Marshalling C# Strings to VC++ 6.0?
From: Scott Ballard on 12 Apr 2010 10:40 Greetings, I'm having difficulty marshalling strings in a C# COM server (VS2008, .NET Framework 2.0) back to a VC++ 6.0 client application. The C++ application wants to consume a single byte per character string, but the C# application is sending it back as a two byte per character string. Fundamentally I know what the problem is (C# strings are UNICODE) I just don't know where/how to inject the code to fix it. Unfortunately I can't touch the C++ application; it must remain unchanged. It was written against a COM interface that defines the method like this in the IDL: HRESULT Foo([in] BSTR incoming, [out] BSTR* outgoing); In C# the interface is defined like this: void Foo([In, MarshalAs(UnmanagedType.BStr) string incoming, [MarshalAs(UnmanagedType.BStr] out string outgoing); I've tried different MarshalAs types and an ICustomMarshaler for the "outgoing" string to no avail (I can provide additional details if needed). The odd thing is the C# COM server has no trouble reading the "incoming" string from C++. I'm really hoping someone can give me a pointer or two on how to do this. Thank you very much for your help. Regards, Scott B.
|
Pages: 1 Prev: Sync DB between Windows Mobile and MySQL - manually ? Next: Marshalling C# Strings to VC++ 6.0? |