Hi all,

I have, unfortunately, another Interop problem with Mono. Using a struct
like this:

    [StructLayout(LayoutKind.Sequential)]
    internal struct StreamSource
    {
        private TidyBuffer buffer;
        private Stream stream;
    }
, I have the following code:

            StreamSource data = new StreamSource();
            data.stream = stream;
            IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(data));
            Marshal.StructureToPtr(data, ptr, true);

which runs fine on Windows and Microsoft .NET, but crashes badly on Mono:

** ERROR **: Type System.MarshalByRefObject which is passed to unmanaged
code must have a StructLayout attribute
aborting...
Stacktrace:

  at (wrapper managed-to-native)
System.Runtime.InteropServices.Marshal.StructureToPtr
(object,intptr,bool) <0x00004>
  at (wrapper managed-to-native)
System.Runtime.InteropServices.Marshal.StructureToPtr
(object,intptr,bool) <0xffffffff>
  at (...)

So, obviously, the question is: what am I doing wrong, if anything?

Thanks in advance!

Frederik.
_______________________________________________
Mono-list maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-list

Reply via email to