Marshalling Simple Structures

The .NET Compact Framework can marshal simple structures between the managed and native worlds. Unlike the full desktop .NET Framework, there are strong restrictions governing what kinds of structures can be marshalled automatically.

First, the .NET Compact Framework marshals all simple structures by reference. Thus, the native side sees parameters that are structures as pointers to the structure. As such, the native code can alter the contents of structures, and the alterations are visible as side effects on the managed side.

Another important rule is that only references to “shallow” structures can be marshalled automatically. This means that the structure can contain an arbitrary number of fundamental data types, ...

Get Microsoft® .NET Compact Framework Kick Start now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.