G
Guest
i have a large C++ data structure that i'm trying to interop with... the
structure is 77400 bytes long. i have the structure defined in C#, so i was
trying to just use "ref <structure>" as the method parameter.
if i use this direct approach, i get the error:
Message: Cannot marshal 'parameter #1': Internal limitation: structure is
too complex or too large."
is there a 64k limit on marshalling structures? what workarounds are there
for this?
i've tried a workaround of using:
IntPtr ptr = Marshal.AllocHGlobal(77400);
// call C++ method to initialize structure
init_method(ptr);
<structure> = (<structure type>)Marshal.PtrToStructure(ptr,
typeof(<structure type>);
// fill in data structure fields...
Marshal.StructureToPtr(<structure>, ptr, false);
// call C++ method to open file
err = open_method(ptr);
now... this method completes properly, but with an error code returned from
the method. i've run the exact same code in a native C++ project and it
works fine and returns a success code.
is there anything obviously wrong with this workaround?
thanks,
Kirk
structure is 77400 bytes long. i have the structure defined in C#, so i was
trying to just use "ref <structure>" as the method parameter.
if i use this direct approach, i get the error:
Message: Cannot marshal 'parameter #1': Internal limitation: structure is
too complex or too large."
is there a 64k limit on marshalling structures? what workarounds are there
for this?
i've tried a workaround of using:
IntPtr ptr = Marshal.AllocHGlobal(77400);
// call C++ method to initialize structure
init_method(ptr);
<structure> = (<structure type>)Marshal.PtrToStructure(ptr,
typeof(<structure type>);
// fill in data structure fields...
Marshal.StructureToPtr(<structure>, ptr, false);
// call C++ method to open file
err = open_method(ptr);
now... this method completes properly, but with an error code returned from
the method. i've run the exact same code in a native C++ project and it
works fine and returns a success code.
is there anything obviously wrong with this workaround?
thanks,
Kirk