I have an array of arrays that I want to pass into a DLL. I am running into the error "There is no marshaling support for nested arrays."
I can pass a single array in fine but if I stack them up it fails. I need/want a "safe" way of passing in the array of arrays.
private static extern int PrintStuff(string[][] someStringsInGroups, int numberOfGroups, int[] lengthSetsInGroups);
EDIT: I am also willing, with enough discouragement and anguish, to accept a solution involving marshaling.
I just stumbled across what may not be as safe but a lot faster since only the pointers are getting allocated.
http://www.mycsharp.de/wbb2/thread.php?threadid=82380
It is in German, but the code at the end of the page is ready for copy/paste. In my case I just made the class generic to not only support doubles.
Mind you, I do not know about string[][] since I would assume string to be marshalled to char*, so you would have char[][]* rather than double[][] as in the example.
You could convert the double array to a single array (i.e. flatten it). This can be done by keeping width and height variables, and accessing the indices as such:
The array can then be converted as such: