I have a method in unmaged COM object which I'm trying to marshall:
STDMETHOD(SomeMethod)(LPSTR** items, INT* numOfItems) = 0;
But I can't figure out the right way to marshal out LPSTR** items. It's supposed to be a list of items. However if try to do something like this:
[PreserveSig]
int SomeMethod([MarshalAs(UnmanagedType.LPStr)]ref StringBuilder items, ref uint numOfItems);
I only get the very first letter of the very first item and nothing else.
How can I marshal LPSTR** variable correctly?
I cannot check it right now, but signature should look like this:
[PreserveSig]
int SomeMethod(
[MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPStr, SizeParamIndex = 1)] out string[] items,
out int numOfItems);
Of course, it is doesn't help, you can always perform manual marshalling via Marshal class (as Sinatr suggested).