Hi,

How do I marshal an array of strings in a structure. My unmanaged struct
looks like this:

Unmanaged struct (C++):

typedef WCHAR String80[81];
typedef struct
{
        double fNumbers[50];
        String80 chString[100];
}

I have tried this in the managed struct (C#)

struct
{
        [MarshalAs(UnmanagedType.ByValArray,
ArraySubType=UnmanagedType.LPArray, SizeConst=50)] public double[] numbers;
        [MarshalAs(UnmanagedType.ByValArray,
ArraySubType=UnmanagedType.LPWStr, SizeConst=100)] public string[] strings;
}

But when I call Marshal.SizeOf()) it fails with: "...can not be marshaled as
an unmanaged structure; no meaningful size or offset can be computed"
If I comment out the array of strings it is ok, so the array of double is
ok.

Any idea of what to do?

Regards,
Henrik.

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to