O'Reilly logo

Professional Windows® Embedded Compact 7 by Thierry Joubert, David Jones, Samuel Phung

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

COMMUNICATING FROM NATIVE TO MANAGED CODE

The .NET Compact Framework provided with Windows Embedded Compact 7 offers several techniques to call managed code from native code. If you compare with the desktop .NET Framework, some techniques are missing, some are the same, and you can even find one which is unique to the Compact Framework.

The structural difference between native and managed environments creates a huge difference when you have to make a direct call to a function inside the other. Native code Dynamic Link Libraries were introduced in the early days of Windows 1.0 to 3.0 to save memory; the library code was not included in the executable; and several programs shared the whole content of a DLL at runtime. Things haven’t changed that much with 32-bit environments; the code inside a DLL is still shared between applications, but the data isn’t shared anymore. Because it is meant to be used by a linker and a loader, the interface of a DLL is extremely simple — imagine a table of direct pointers to binary code. The export table of a DLL doesn’t contain function prototypes, therefore no syntax check is possible during compilation or linking — everything depends on the prototype declared by the user of the DLL. For example you can compile and link a one parameter function call that ends up in a two parameter function code at runtime, thus creating an unstable situation. This extreme simplicity of the DLL interface combined with late binding provided unprecedented flexibility ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required