A View of Windows Mobile 5.0 from 10,000 Feet

 

Jim Wilson
JW Hedgehog, Inc.

September 2005

Applies to:
   Microsoft .NET Compact Framework version 2.0
   Windows Mobile 5.0
   Microsoft Visual Studio 2005

Summary: Jim begins a series of articles exploring the new tools and application programming interfaces (APIs) that developers will find in Microsoft Windows Mobile 5.0, Visual Studio 2005, and the .NET Compact Framework version 2.0. The series begins with an introduction to Windows Mobile 5.0 and the tools needed to get started developing for Windows Mobile 5.0 today. (9 printed pages)

Contents

Introduction
A Sampling of the New APIs
Windows Mobile 5.0 APIs for Managed Developers
Windows Mobile 5.0 Development Tools
Deployment Landscape
Conclusion

Introduction

It's been a few months since my last column, and what a great time to return. Those of you who read the first edition of this column know that what originally motivated me to start writing it is my belief that we have finally reached the era of widespread enterprise-level mobile application development and delivery. Today, I am more convinced than ever that this is true.

Over the past year since this column was started, developers have continued to push the capabilities of both the Windows Mobile platform and the development tools to produce increasingly powerful applications. As developers gain more experience with developing mobile applications and as both individuals and organizations experience the benefits they can offer, the expectations surrounding these applications will continue to grow.

To provide developers with a platform for building mobile applications to meet these growing expectations, Microsoft has released Windows Mobile 5.0. The release was announced at the beginning of May during the U.S. Microsoft Mobile and Embedded DevCon. Windows Mobile 5.0-based devices should start becoming available for purchase in coming months. Combined with Microsoft Visual Studio 2005 and the .NET Compact Framework version 2.0, Windows Mobile 5.0 creates a tremendous opportunity for developers to push their applications further than ever before.

We will be spending the next many months taking a detailed look at various features of Windows Mobile 5.0, Visual Studio 2005, and the .NET Compact Framework 2.0. To get our investigation started, this month's column provides an overview of Windows Mobile 5.0 and the tools available to get you started developing Windows Mobile 5.0–based applications today. Next month's column will begin our detailed investigation with a close look at the Windows Mobile 5.0 State and Notifications Broker API.

A Sampling of the New APIs

Windows Mobile 5.0 provides many new APIs beyond those provided by its predecessor Windows Mobile 2003 Second Edition (also known as Windows Mobile 2003 SE). Most of these new APIs are designed to free developers to focus on application development issues because many common device and system issues are now encapsulated in the Windows Mobile 5.0 platform. This is true whether you are developing personal, enterprise, or gaming software.

A few of the new features are:

  • Rich graphics and multimedia support through Direct3D Mobile and DirectDraw. Integrated support for Global Positioning System (GPS) devices, including an easy-to-use API and support for providing multiple applications with simultaneous access to GPS data.
  • Integrated camera support through two new APIs. The Camera Capture API is an easy-to-use, high-level API for taking and viewing pictures; for developers needing detailed control of the camera hardware, DirectShow is now available.
  • An enhanced Pocket Outlook API that includes the ability for applications to store custom data in the Pocket Outlook database and subscribe to notifications of changes to Pocket Outlook data.
  • New messaging APIs that provide the ability to easily view, compose, and send messages from within your application.
  • Access to a device's unique identifier through the GetDeviceUniqueID function.
  • A common digital rights management (DRM) programming model across DRM engines through the new File-Based Digital Rights Management (FDRM) API.
  • A common architecture for tracking changes in system status such as an incoming phone call or the availability of network connectivity through the State and Notification Broker API provides.

Note   The State and Notification Broker API is a very powerful API that addresses many issues related to monitoring and interrogating system status. Because it is one of the most significant new APIs in Windows Mobile 5.0, it will be the first Windows Mobile 5.0 API that we investigate in detail and will be the subject of next month's column.

You can see that these new Windows Mobile 5.0 APIs provide out-of-the-box support for many tasks we've previously had to program manually. Having these features as part of the platform provides faster application development, and the ease of access to rich device features enables us to incorporate the capabilities of the hardware more completely in our applications.

Windows Mobile 5.0 APIs for Managed Developers

Those of you who are managed application developers may be looking at the list of new Windows Mobile 5.0 APIs and wondering how much extra work it will take for you to access the new APIs from Microsoft C# or Microsoft Visual Basic .NET. You'll be happy to know that accessing most of the new APIs will require no extra work. This is because Windows Mobile 5.0 no longer limits exposing platform features through native APIs and now exposes many platform features through managed APIs as well. This means that Visual C# and Visual Basic .NET developers can access these features without needing to write C DLLs or to use the platform invoke (P/Invoke) feature of the .NET Compact Framework.

The introduction of managed APIs to the Windows Mobile 5.0 platform is an important advance as it enables managed application developers who want to take advantage of the capabilities of the Windows Mobile 5.0 platform to do so without being limited by the features provided by the classes included in a particular version of the .NET Compact Framework. This may seem a bit confusing at first, but actually makes a great deal of sense.

The .NET Compact Framework provides a general purpose set of classes used to develop a wide range of programs across a wide range of hardware. Developers using the .NET Compact Framework commonly want the applications they build to run on the broadest number of platforms possible. A single .NET Compact Framework application may need to run on a Windows Mobile 2003 Pocket PC, Windows Mobile 2003 SE Pocket PC, Windows Mobile 5.0 Pocket PC and possibly several special purpose devices running Windows CE. The .NET Compact Framework makes this possible by providing classes that offer a level of functionality that is common to a broad family of devices.

As useful as these general purpose classes are, there are times when an application developer needs to take advantage of the features offered by a particular platform. This is especially true in cases where a platform provides substantially improved capabilities over its predecessor as in the case of Windows Mobile 5.0. The Windows Mobile 5.0 managed APIs are developed and maintained by the Windows Mobile team with the intention of providing managed developers with the ability to take advantage of the rich feature set provided by the Windows Mobile 5.0 platform.

Windows Mobile 5.0 includes the six managed assemblies listed in Table 1.

Table 1. Windows Mobile 5.0 Managed Assemblies

Assembly Description
Microsoft.WindowsMobile Contains types required by other Windows Mobile 5.0 assemblies
Microsoft.WindowsMobile.Configuration Contains the ConfigurationManager class which provides access to the Windows Mobile XML configuration engine
Microsoft.WindowsMobile.Forms Contains several Form-derived classes such as SelectPictureDialog, CameraCaptureDialog and ContactChooser
Microsoft.WindowsMobile.PocketOutlook Contains Pocket Outlook managed types
Microsoft.WindowsMobile.Status Contains the State and Notification Broker API types
Microsoft.WindowsMobile.Telephony Contains types for interacting with the device phone hardware

The Windows Mobile 5.0 managed assemblies provide managed developers with access both to platform features that are newly introduced with the Windows Mobile 5.0 platform and to features that existed in earlier versions of Windows Mobile but only exposed native APIs. For example, the types contained in the Microsoft.WindowsMobile.Configuration assembly provide managed developers with access to the features originally offered by the native function DMProcessConfigXML that was introduced in the Windows Mobile 2003 platform. Whereas the types contained in the Microsoft.WindowsMobile.Status provide access to the State and Notification Broker that was newly introduced as part of Windows Mobile 5.0. The Microsoft.WindowsMobile.PocketOutlook assembly is a special case because it provides a managed implementation of both long-standing Pocket Outlook features and those new to the Windows Mobile 5.0 platform.

The key thing to remember is that these managed APIs are tied to the Windows Mobile 5.0 platform not to any version of the .NET Compact Framework. Whether your application targets the .NET Compact Framework version 1.0 or the .NET Compact Framework 2.0, the Windows Mobile 5.0 managed assemblies are equally accessible as long as the application is running on a Windows Mobile 5.0–based device or emulator.

Windows Mobile 5.0 Development Tools

Although you may not have access to Windows Mobile 5.0–based Pocket PCs or Windows Mobile 5.0–based Smartphones, you can begin developing Windows Mobile 5.0–based applications today. You'll just need to install a few tools to get started.

Visual Studio 2005

As you might expect, Windows Mobile 5.0–based devices are backward compatible with programs written for earlier Windows Mobile platforms. These earlier programs will normally run fine on Windows Mobile 5.0–based devices. However, Windows Mobile 5.0 is not backward compatible with earlier development environments. Visual Studio 2005 is the only development tool that is able to deploy and debug applications to Windows Mobile 5.0–based devices and emulators. This is true for both native and managed developers.

The reason Windows Mobile 5.0 development requires Visual Studio 2005 is due to changes in the connectivity layer used to communicate between the development environment and the device or emulator. This communications layer has been completely rearchitected to make it more robust and reliable. Because the communications layer is new, the existing environments such as Microsoft eMbedded Visual C++ version 4.0 and Microsoft Visual Studio .NET 2003 are unable to support it.

Note Although Windows Mobile 5.0–based applications can only be deployed to and debugged by Visual Studio 2005, Visual Studio 2005 is not limited to deploying and debugging only Windows Mobile 5.0–based applications. Visual Studio 2005 can also deploy and debug applications on all devices and emulators running Windows Mobile 2003 or Windows Mobile 2003 SE software.

Visual Studio 2005 includes the .NET Compact Framework 1.0, .NET Compact Framework 2.0, an updated C++ compiler, and Microsoft SQL Server 2005 Mobile Edition. At the time this article is being written, the current version of Visual Studio 2005 is Visual Studio 2005 Beta 2. Microsoft has announced that the final version of Visual Studio 2005 will be available on November 7, 2005.

Note SQL Server 2005 Mobile Edition is the new name for SQL Server Windows CE Edition (SQL Server CE). You can think of it as version 3.0 of SQL Server CE. SQL Server 2005 Mobile Edition provides many new features, including support for multiple concurrent connections and integration with Visual Studio 2005 to allow you to create, manage, and diagram smart device databases from your desktop computer. We'll discuss SQL Server 2005 Mobile Edition in detail in a future article.

ActiveSync 4.0

In addition to installing the Windows Mobile 5.0 software development kits (SDKs), you will also need to install ActiveSync 4.0 as Windows Mobile 5.0–based devices will not sync with earlier versions of ActiveSync technology. Once you have ActiveSync 4.0 installed, you can also use it to connect to the emulators. To launch the Emulator Manager, click Device Emulator Manager… on the Visual Studio 2005 Tools menu. When the Emulator Manager opens, select the emulator you would like to connect to from the displayed list, and then click Cradle on the Actions menu.

Windows Mobile 5.0 SDKs

With Visual Studio 2005 being the required development tool for Windows Mobile 5.0, you might expect that Visual Studio 2005 ships with everything you need to start developing Windows Mobile 5.0–based applications. Unfortunately, that's not the case. Before you can develop Windows Mobile 5.0–based applications, you must first install either the Windows Mobile 5.0 SDK for Pocket PC or the Windows Mobile 5.0 SDK for Smartphone. Of course, you can install both if you are developing applications for both kinds of devices. Installing the SDKs performs the following actions:

  • Creates new project templates
  • Installs design-time versions of the assemblies listed in table 1 for use by managed developers targeting Windows Mobile 5.0
  • Installs header files and libraries for use by native developers targeting Windows Mobile 5.0
  • Installs the Windows Mobile 5.0 emulators

Figure 1 shows the Visual Studio 2005 New Project Dialog with the C# Smart Device projects expanded after installing Windows Mobile 5.0 SDKs for Pocket PC and/or Smartphone. The three project types Windows CE 5.0, Pocket PC Magneto, and Smartphone Magneto and their corresponding templates were all created by installing the two SDKs. The word "Magneto" appearing in the project type names may seem strange, and it will likely not appear in the final release of Visual Studio 2005 because it's an artifact of the rush to ship the beta. "Magneto" was the Microsoft code name for Windows Mobile 5.0 during development and appears here only because Visual Studio 2005 is still in beta. The Pocket PC Magneto and Smartphone Magneto project types will most likely be named Pocket PC 5.0 and Smartphone 5.0 respectively in the final Visual Studio 2005 release.

Figure 1. Windows Mobile 5.0 C# project types and templates in Visual Studio 2005. Click the thumbnail for a larger image.

Figure 2 shows the Visual Studio 2005 Add Reference dialog after installing either one or both of the Windows Mobile 5.0 SDKs. You'll notice that the six assemblies listed in table 1 appear in the Add Reference dialog assembly list. Prior to installing one of the Windows Mobile 5.0 SDKs, these assemblies would not be available.

Figure 2. Windows Mobile 5.0 assemblies in the Visual Studio 2005 Add Reference dialog box. Click the thumbnail for a larger image.

If you look closely at figure 1, you'll notice that there are actually seven assemblies whose names start with Microsoft.WindowsMobile. Obviously, this is inconsistent with table 1, which lists only six assemblies. The additional assembly displayed in the Add Reference dialog is Microsoft.WindowsMobile.DirectX. The Microsoft.WindowsMobile.DirectX assembly is a .NET Compact Framework 2.0 assembly that exposes the Windows Mobile 5.0 Direct3D features to managed developers.

As I mentioned previously, Windows Mobile 5.0 provides both native and managed APIs. These APIs are developed and maintained by the Windows Mobile 5.0 team. Many of the Windows Mobile 5.0 platform capabilities expose both native and managed APIs, but some features such as Direct3D expose only native APIs. In cases where no managed version of the API is provided, managed developers must use the P/Invoke feature of the .NET Compact Framework to call out to the native API. As many of you have already experienced, accessing a complex API through P/Invoke can be a time-consuming task. In the case of Direct3D, which is a relatively sophisticated API, the .NET Compact Framework team has provided that wrapper for you. Although it's a minor point, its worth noting that this means that Direct3D is available to native developers directly from the Windows Mobile 5.0 platform, whereas managed developers must install the .NET Compact Framework 2.0 on the device or emulator to access this feature.

Emulator Performance Patch

The final thing to install is the Emulator Performance Patch, which is also known as the Direct Memory Access (DMA) Transport Update. The patch installs the necessary components and applies the required settings for Visual Studio 2005 to communicate with the emulators using DMA rather than IP resulting in substantially faster communication. Once installed, the patch results in a much faster and far more pleasant development experience when deploying and debugging applications on the emulators. This patch is not required but is strongly recommended.

Deployment Landscape

As has always been the case, Microsoft sets very concise guidelines for the configuration of Windows Mobile–based devices. This has not changed with Windows Mobile 5.0. Before I close for the month, I want to cover a few of the notable requirements of Windows Mobile 5.0–based devices that will affect how you develop and deploy programs.

.NET Compact Framework Versions

We've already discussed the fact that Windows Mobile 5.0 exposes managed APIs, so it is logical that Windows Mobile 5.0–based devices must ship with the .NET Compact Framework installed in ROM. Given that Visual Studio 2005, which includes the .NET Compact Framework 2.0, is the required development tool for Windows Mobile 5.0, it might also stand to reason that the .NET Compact Framework 2.0 is the .NET Compact Framework version that would be included in Windows Mobile 5.0 device ROM. Although reasonable, this is not the case. Instead, the .NET Compact Framework 1.0 with Service Pack 3 is the version installed in Windows Mobile 5.0 ROM.

I must admit to being quite surprised when I first heard this. But it turns out that the reason is a simple matter of timing. Windows Mobile 5.0 was released back in May. The .NET Compact Framework 2.0, which is coupled with Visual Studio 2005, will not ship until November. The Windows Mobile 5.0 ROM image had to use version 1.0 with Service Pack 3 because it was the newest version of the .NET Compact Framework that was actually shipping.

For most developers, this will be a minor point as you can still develop .NET Compact Framework version 2.0 applications for Windows Mobile 5.0–based devices. You just have to deploy the .NET Compact Framework 2.0 to the device, which does occupy a few extra megabytes of memory on the device. In most cases, the additional features provided by the .NET Compact Framework 2.0, make the extra memory cost worthwhile.

If you need to keep the footprint required by the application as small as possible and you don't feel that you need the additional features provided by the .NET Compact Framework 2.0, you can use one of the Visual Studio 2005 .NET Compact Framework 1.0 project templates to create your application. In this case, only your application needs to be installed on the device because the .NET Compact Framework 1.0 is already installed in the device ROM.

Persistent Store

One very important change in Windows Mobile 5.0-based devices is the introduction of persistent store, which ensures that no data will be lost from the device file system or registry even if the device loses all power. This is achieved by mounting the entire file system and registry in flash memory known as persistent store. Persistent store is automatically made available through the standard file system and registry APIs, so you don't have to do anything special to receive its benefits.

One issue you should be aware of is that persistent store is optimized for large reads and writes. If you have an application that performs a large number of small reads or writes, you may find that it does not perform as well under Windows Mobile 5.0 as it did on earlier versions of Windows Mobile. Modifying the application to group the file operations into larger chunks will generally yield substantially improved performance.

Conclusion

You can see that Windows Mobile 5.0 provides an unmatched platform for developing mobile device applications. The introduction of many powerful new APIs, including managed versions of many of them, makes it the most developer-friendly Windows Mobile platform we've seen. When we combine Windows Mobile 5.0 with Visual Studio 2005, we can build better applications with less effort then ever before.

Due to space limitations, our discussion has had to remain at a fairly high level, but hopefully I've been able to give you an idea of the capabilities of Windows Mobile 5.0. For a much more detailed discussion of Windows Mobile 5.0 APIs, tools, and the platform itself, check out What's New for Developers in Windows Mobile 5.0

Please join me next month as we continue looking at the new APIs, tools, and platforms available to Windows Mobile developers. As I mentioned previously, next month begins our detailed look at individual APIs. We'll be starting with the State and Notifications Broker API (SNAPI). Trust me; you won't want to miss next month's column. SNAPI is the API we've all been waiting for—especially for applications that need to detect changes in network availability or work closely with any aspect of system status.