Migrating Applications to the .NET Compact Framework c2.0 and Windows Mobile 5.0
Menus and Pocket PCs
Smartphone developers have long been used to a specialized menu system for Windows Mobile applications. The soft key menu system provides the user with menu access without the need of a stylus. Users instead use specially mapped keys to activate and navigate to proper menu items. Starting with Windows Mobile 5.0, soft key menu functionality has been extended to Pocket PC and Pocket PC Phone Edition devices.
To enable soft key functionality, the main menu bar for a given menu structure must have either one or two menu items. Figure 3 shows a menu for a form with two menu items added. The figure also points out the associated key mappings to the menu items.
Figure 3: Soft key menu for Windows Mobile 5.0 Pocket PC
When working in Visual Studio 2005, the menu editor behaves in a fashion similar to Visual Studio.NET 2003, with the only difference being the layout of menu items in relation to the soft key functionality. Editing of menu items occurs in the same way as before, as seen in Figure 4.
Figure 4: Editing menus in Visual Studio 2005
When adding a third menu item to the main menu bar for a Windows Mobile 5.0 application, you will notice something quite different suddenly displays. The menu bar reverts back to the traditional menu style for Pocket PCs! Figure 5 demonstrates this change.
Figure 5: Menu bar reverting to "classic" Pocket PC style
As a Pocket PC developer, this behavior provides a sort of "good news/bad news" scenario for your application. The good news—existing .NET Compact Framework applications can be migrated to Windows Mobile 5.0 without having to change the menu system. The bad news—soft key menus are an expected behavior and functionality for Windows Mobile 5.0 Pocket PC users. To be truly compatible with the platform, you should strongly consider migrating any "old" menus to take advantage of the soft key functionality.
If your application is based on ADOCE and CEDB databases for data storage, you should be aware that the ADOCE runtime is no longer part of the ROM image in Windows Mobile 5.0. ADOCE and CEDB have officially been deprecated. According to the Windows Mobile Platform Migration FAQ for Developers (http://msdn.microsoft.com/mobility/windowsmobile/default.aspx?pull=/library/en-us/dnppcgen/html/migration_developers_faq.asp), an ADOCE runtime and ActiveSync Service Provider will eventually be made available as a separate download and install. Considering that it is unlikely that future Windows Mobile versions will provide even this level of support, now would likely be a good time to consider migrating your application to SQL Mobile and ADO.NET as your data solution.
Pocket Outlook/MAPI Access
Prior to Windows Mobile 5.0, you may have used P/Invoke functionality to directly access stored data for Contacts, Tasks, and Appointments in your .NET Compact Framework application. The underlying data storage for this information was CEDB. This, too, has changed for Windows Mobile 5.0 and will require you to make changes to your application logic. There is, however, a "silver lining" to this dark cloud; the .NET Compact Framework 2.0 provides a set of managed classes (in the Microsoft.WindowsMobile.PocketOutlook namespace, as shown in Figure 6) that should make the transition somewhat smoother. This namespace also contains classes for the interaction and manipulation of messages (E-Mail and SMS), allowing you to migrate or extend your applications to support messaging functionality.
Figure 6: The Microsoft.WindowsMobile.PocketOutlook namespace.
It is important to note that this namespace is only available for .NET Compact Framework applications that are targeted at Windows Mobile 5.0 devices. If you intend to support Pocket Outlook (now referred to as "Outlook Mobile" for Windows Mobile 5.0) access across operating systems, you will need to maintain separate Visual Studio 2005 projects for this purpose. Fortunately, Peter Foot of In The Hand Ltd and a Microsoft Most Valuable Professional ("MVP") for Windows Embedded has announced Windows Mobile In The Hand, a set of managed APIs that duplicate the Windows Mobile 5.0-specific classes for earlier OSes. You can find out more at Peter's Web site: http://www.inthehand.com.
The Windows Mobile platform has long supported the concept of application signing and trust for Smartphone devices. Starting with Windows Mobile 5.0, this model has been extended to Pocket PC and Pocket PC Phone Edition devices. Fortunately, the behavior for unsigned Pocket PC applications is slightly different than the Smartphone.
If you package a Pocket PC application for Windows Mobile 5.0 devices without a certificate, the user will be informed that they are about to install an unsigned application during the installation process. They can either continue with the installation or abort. By comparison, Smartphone applications' handling of unsigned (and even signed) applications is determined by device configurations that can be implemented by the hardware manufacturer, a cellular carrier, or both. Whether or not you implement application signing for your Pocket PC applications is up to you. Typically, if your application is for "in-house" use, the need to purchase a digital certificate and sign your application is not a priority. If you are selling your application through commercial channels, however, the issue of consumer perception of an "unsafe" application lacking in proper credentials might impact sales.
Microsoft does provide a wealth of information and resources regarding application security and signing at the MSDN Mobile and Embedded Developer Center (http://msdn.microsoft.com/mobility) and the Mobile2Market program home (http://msdn.microsoft.com/mobility/windowsmobile/partners/mobile2market/default.aspx).
Exploring New Managed APIs
In addition to the Outlook Mobile managed APIs mentioned earlier, there are a number of additional new managed APIs available in the .NET Compact Framework 2.0, including:
- Configuration Manager
- State and Notification Broker
- Picture Selection Dialog
- Camera Capture API
There is far too much to go into detail in this article. I will, however, go into far more detail in upcoming articles. This should not stop you from starting to explore these new managed APIs and to see whether you can use them to your advantage in your Windows Mobile 5.0 applications.
With there still being some time until Windows Mobile 5.0 and the .NET Compact Framework 2.0 become widely available, planning and preparing early can provide you with the ability to deliver your migrated Windows Mobile 5.0 application in a timely and effective fashion.
About the Author...
Don Sorcinelli has been involved in the design, development and deployment of enterprise software applications for over 15 years. Don has also worked with mobile and distributed architectures for almost a decade, and has worked with the PDA and Windows Mobile platform since their inceptions.
Don is a frequent presenter on Windows Mobile development and technologies for MSDN, developer groups and conferences. He is also the Manager of the Boston Windows Mobile Developer Group and founder of BostonPocketPC.com, a web site focused on Microsoft mobile technologies.
Page 2 of 2