Executive Summary

Although the Compact Framework, coupled with SDP, provides a rich feature set for building applications, not everything you and your team need is included in the box. Developing professional applications also involves creating applications that perform well. As a result, you'll likely need to augment the Compact Framework and employ some techniques for instrumenting and profiling the code your team writes.

The most obvious way to augment the Compact Framework, which is, after all, a 25% subset of the desktop Framework, is to call unmanaged functions either in the Windows CE API or in custom DLLs that you leverage from existing applications. Some of the reasons to use the Windows CE API include checking the platform of the device, enabling notification, using the RAPI, making phone calls, and processing Short Message Service (SMS) messages, manipulating the registry, and interacting with the system tray.

In order to take advantage of this functionality, Compact Framework developers need to use the PInvoke service. This service (also exposed in the desktop Framework) allows managed code to declare and invoke unmanaged functions residing in DLLs, using the Declare statement in VB or the DllImportAttribute in both C# and VB. The typical strategy used with PInvoke is to wrap a related set of functions in a class and expose the functionality through static methods.

Although PInvoke in the Compact Framework is very much like that in the desktop Framework, there are subtle differences that include the exclusive use of Unicode and the inability to marshal strings in complex types such as structures. As a result, developers must work around these issues using a variety of low-level techniques.

In addition to augmenting the Compact Framework using PInvoke, Microsoft has made available for download additional tools. These include a remote display control (RDC) for interacting with a cradled device on the desktop, a tool for connecting VS .NET to devices that don't support ActiveSync, the Pocket PC 2003 SDK, which includes new emulators and increased functionality, and a set of handy utilities developed by the Compact Framework team.

Finally, developers always face the challenge of creating applications that perform well. The Compact Framework helps the process by allowing accurate timings to be made for profiling and providing EE performance counters. Developers should also be aware of performance tradeoffs and issues when dealing with data binding, retrieving data, loading forms, and working with strings.