Passing Nested Structures by Using Custom Marshalling Code
As previously noted, the .NET Compact Framework cannot automatically marshal deep structures between the native and managed worlds. If you are in a position where you absolutely must marshal a deep structure between native and managed code, then you will have to write custom marshalling code. This sounds daunting, and it is tricky.
The fundamental idea to writing custom marshalling code is that the nested structure has a specific layout in memory. On the native side, creating a nested structure means that you have deliberately created this layout and populated it with values. On the managed side, you must duplicate the exact same memory layout with managed structures and then pass a reference ...
Get Microsoft® .NET Compact Framework Kick Start now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.