Return to DNJ Online home page

 

The .NET Platform
Development Tools
COM & COM+
Data Access
Web Development
XML Technologies
Windows Servers
Wireless & Mobile
Security issues
Design & Process
Career Development
Analysis & Comment
Disposable Objects

Subscribe to our RSS feed to receive notification of new articles as they are published.

Events Diary
Software Update

About Us
Advertisers


You are not logged in: login here to access all areas.


Tools for writing mobile software

Matt Nicholson explains how Microsoft?s range of mobile tools and platforms support a number of different application architectures.

Author: Matt Nicholson

Last updated: Mar 2004

Developing applications for mobile devices, or extending existing applications to take advantage of mobile devices, can appear daunting. The market is moving so fast, and there are so many different standards, that deriving a viable long-term strategy seems impossible.
      Microsoft has approached this problem by extending its existing tools out into the mobile world, and by developing an operating system for mobile devices that offers an API consistent with its desktop counterparts. This at least ensures developers can work in a familiar environment when they enter this brave new world. Microsoft’s mobile platforms come under the generic Windows Mobile brand, with the current iteration being Windows Mobile 2003.
      Mobile devices come in different shapes and sizes. On the one hand are Personal Digital Assistants (PDAs) that have a relatively large screen and respectable processing and storage capabilities. Microsoft’s principal platform here is Pocket PC which is based on the Windows CE operating system. The latest version is Pocket PC 2003 which, like all Windows Mobile 2003 platforms, is based on Windows CE 4.2 and processors compatible with Intel’s ARM instruction set. Competing platforms include Palm and Handspring.
      On the other hand are mobile phones which offer much less in the way of local storage and processing power but provide data connectivity through GSM, GPRS or 3GSM. Many of these can browse the Internet through their support of WML (WAP Markup Language) although these are being replaced by devices capable of displaying HTML.
      More recently we have seen hybrid devices emerging which combine wireless connectivity, whether through wide-area technologies such as GPRS or through more local-area technologies such as Wi-Fi, with more powerful processing and storage capabilities. Microsoft has moved into this space with two platforms, again based on Windows CE. As its name suggests, Pocket PC Phone Edition adds connectivity to the Pocket PC platform. The other is Smartphone which offers a smaller platform designed for a new generation of mobile handset. Current versions are Pocket PC 2003 and Smartphone 2003. These compete with a wide range of platforms offering Web browsing facilities or supporting J2ME (Java 2 Micro Edition).
      One of the strengths of Microsoft’s strategy in this market is the wide range of options it allows you to take when designing applications for such devices, which we will now examine in more detail.

The ASP.NET approach
One option is to extend the Web application model where the bulk of the processing is carried out on back-end servers which deliver the application interface to mobile devices as HTML or WML pages. The advantage of such an approach is the wide range of devices that can be accommodated. The disadvantage is that the application can only work when the mobile device is connected to the server.
      At the heart of Microsoft’s platform for delivering Web applications is the .NET Framework, and at the core of the .NET Framework is the Common Language Runtime (CLR). Code written for the .NET Framework is not compiled directly to binary code but instead to Microsoft Intermediate Language (MSIL) which is in turn compiled to binary code by the high-performance compiler built in to the CLR.
      It is the CLR that activates objects, performs security checks, verifies type safety and allocates memory. It also manages memory through an extremely efficient garbage collector. As a result, code written for the .NET Framework (usually referred to as ‘managed’ code) tends to be more reliable and more secure than code that is compiled directly to machine code, and so does not take advantage of the services offered by the CLR.
      The .NET Framework comes with one of the largest class libraries ever built, containing over 5,000 classes divided into a set of over 90 namespaces. One of these is the System.Web namespace which replaces Active Server Page (ASP) technology with a coherent set of classes for generating dynamic HTML-based content and XML Web Services which is called ASP.NET. You can write ASP.NET applications using any of the languages supported by Visual Studio .NET, including Visual Basic .NET, C# and J#, and these applications can access corporate databases and legacy systems through ADO.NET, or any of the other integration libraries that come with the .NET Framework. They can also make use of the COM+ Services built into Windows 2000 and Windows Server 2003.
      Microsoft has extended ASP.NET to cater for mobile devices through the provision of ASP.NET Mobile Controls. These are server-side controls that emit HTML or WML in a form suitable for mobile devices, which is then tailored to the needs of specific devices by installable Device Adapters. The technology has been tested with more than 200 third-party devices and supports WAP, iMode, Palm, Symbian and Handspring browsers, as well as Pocket Internet Explorer which is included with Pocket PC and Smartphone.
      You work with ASP.NET Mobile Controls within the Visual Studio .NET environment in much the same way as you would conventional ASP.NET controls, although there are some differences. For example, you can place multiple Mobile Web Forms on a single page, each containing different Mobile Controls. If the target is a WAP device then all the forms are downloaded in one go, and the user can navigate between them without further traffic between the device and the server. If the device uses a Web browser then each form is downloaded as a separate HTML document.
      This technology is included in Visual Studio .NET 2003. The .NET Framework itself is built in to Windows Server 2003, or is available as a free download for use with earlier versions of Windows.
      The ASP.NET approach is ideal if you need to target a wide range of devices, as for example in a ticket-booking service that is available to the general public. However the application can only function when the client device is connected to the server. If the user wanders out of range, or is unable to attach to the Internet, then the application ceases to function. This architecture is not suited to applications where the user wants to collect data on the client for later synchronisation when a connection can be established, or for stand-alone applications that rely on the processing and data handling capabilities of the device itself. Such applications require a different approach.

The Managed approach
Although the Pocket PC and the Smartphone function as very viable ASP.NET client, such an approach does not make best use of the considerable computing power available on the device itself. These days a Pocket PC can contain a 400MHz 32-bit processor linked to 128Mb of memory, or up to 1Gb through CompactFlash cards, which is equivalent in power to a typical desktop PC only a few years ago.
      To take advantage of this power, Microsoft has developed the .NET Compact Framework. This is an implementation of the .NET Framework targeted at devices running Windows CE .NET. It is supported by Pocket PC 2002 and 2003, and by Smartphone 2003, but not by older Smartphone 2002 devices.
      The .NET Compact Framework uses the same programming model as its big brother, and includes a compact version of the CLR. However it is optimised for devices with smaller resources and saves memory by providing a subset of the .NET Framework class library. For full details, see our article elsewhere (click here).
      Visual Studio .NET 2003 includes the .NET Compact Framework together with the tools you need to write .NET applications for mobile devices in either Visual Basic .NET or C#. Windows CE .NET includes the .NET Compact Framework as one of its component parts which means hardware manufacturers can use the Windows CE .NET Platform Builder to install .NET Compact Framework onto their devices. Alternatively, the .NET Compact Framework can be downloaded from a desktop PC and installed onto a Windows Mobile device using ActiveSync, either as part of an application installation or on its own.
      The .NET Compact Framework offers many options for persisting data on the device, and for synchronising locally-stored data with server-side data. Synchronisation can be achieved through ActiveSync, or the mobile application can interact with a Web Service exposed by the server. All these options are supported by the ADO.NET classes provided by the .NET Compact Framework.
      However the most powerful option for data storage is that provided by SQL Server CE. This relational database management system delivers a remarkably large subset of the facilities provided by SQL Server itself, including a fully compatible set of data types, all in a footprint of under 2Mb. Features include enforced referential integrity with cascading deletes and updates, multi-column indexing with up to 32 indexes per table, scrollable and forward only cursors, and 128-bit data file encryption.
      SQL Server CE offers two techniques for synchronising with SQL Server itself, both achieved using HTTP. On the one hand, Remote Data Access (RDA) provides a rather crude mechanism for pushing or pulling data between SQL Server CE and either SQL Server 7.0 or SQL Server 2000. Alternatively, the SQL Server CE Replication object allows you to perform a full merge replication with SQL Server 2000. Communication is achieved through an ISAPI filter called the SQL Server CE Agent which must be installed into Internet Information Server (IIS).
      SQL Server CE has been around rather longer than the .NET Compact Framework. However version 2.0 has been specifically designed to work with managed code. In particular, the new Data Access Architecture provides .NET classes for managing replication and Remote Data Access. Interaction with the data itself is achieved through ADO.NET.

Native code applications
The alternative to a managed application, running under .NET Compact Framework, is a native code or ‘unmanaged’ application running directly against the Windows CE API. This is the only type of application that will run on older Smartphone 2002 devices, and there are still plenty of instances on the Pocket PC and Smartphone 2003 platforms where native code makes more sense.
      Developing native code applications for Windows CE devices such as the Pocket PC or Smartphone is achieved using either the eMbedded Visual Tools 3.0 suite or eMbedded Visual C++ 4.0.
      The eMbedded Visual Tools 3.0 suite includes two stand-alone development environments, both similar to the Visual Studio 6.0 environment. The first is eMbedded Visual C++ (eVC) 3.0 which includes versions of both MFC (Microsoft Foundation Classes) and ATL (ActiveX Template Libraries) and allows you to build high-speed applications, components or device drivers that run as native code on the device.
      The second is eMbedded Visual Basic (eVB) 3.0 which is more like VBScript than Visual Basic itself. This is an interpreted language, requiring installation of a runtime on the device itself, and does not include support for class modules. The eVB environment is being phased out and it is now only supported for Pocket PC 2002 devices. Both eVC and eVB support ActiveX Data Objects for Windows CE (ADOCE), which gives you access to SQL Server CE (see above).
      These development environments are supported by the Software Development Kit (SDK) appropriate to the target device. The suite comes with SDKs for all Windows Mobile platforms, including the Pocket PC 2003 SDK and the Smartphone 2003 SDK. While the Pocket PC 2002 SDK supports development in both eVB and eVC++, all other Windows Mobile SDKs support only eVC++.
      The SDKs include a range of useful tools such as the Remote Registry Editor, Remote Heap Walker and Remote Process Viewer which help you debug your application through the device’s USB or serial port as it runs on the device itself. Both also include emulators for testing your application locally. These emulators actually run Windows CE binaries within a virtual machine on your desktop, making them far more accurate than those of earlier SDKs.
      The SDKs also give you access to the Pocket Outlook Object Model (POOM), which allows you to hook your applications into Pocket Outlook. Using POOM you could, for example, extend the Pocket Outlook Tools menu to display an order history for the current contact, based on data extracted from SQL Server CE.
      The eMbedded Visual Tools 3.0 suite is targeted at the Windows CE 3.0 operating system, rather than Windows CE .NET. Microsoft has released eVC++ 4.0 for developers wishing to work with Windows CE .NET. There will not be a new version of eVB as Visual Basic programmers will be able to use Visual Basic .NET itself to write managed code for the .NET Compact Framework.
      New features of eVC++ 4.0 include support for catch/throw exception handling as well as Win32 structured exception handling, Standard Template Library (STL) support, and access to Run Time Type Information (RTTI) which allows you to determine object type at runtime. There is also full support for the new debugging features enabled by Windows CE .NET, and a new call trace tool in the Remote Call Profiler.
      Note that eVC++ 3.0 is still needed if you wish to write native code for the Pocket PC 2002 and Smartphone 2002 platforms. However eVC++ 4.0 can be installed on the same machine as eVC++ 3.0 without causing problems.

Making your choice
Microsoft is well known for the quality of its development tools, and this continues when it comes to developing for mobile devices. The key is familiarity. Even if you are using the eMbedded Visual Tools suite to develop native code applications for the Pocket PC or Smartphone, you will still find yourself in a familiar environment, working with familiar languages, and programming against a familiar API.
      If your target is the .NET Compact Framework, or you’re building an ASP.NET application that targets mobile devices, then you can use the same tools as you would building a standard desktop or server application, and be able to take full advantage of all the facilities provided by Visual Studio .NET. You will of course have to familiarise yourself with the .NET Compact Framework, or the ASP.NET Mobile Controls, but you won’t have to learn a completely different operating system, or get to grips with a completely new toolset.
      As a result, mobile software development need no longer be seen as a specialist area, requiring specialist tools and specialist skills. Instead developers can integrate mobile devices into their applications using the same tools and technologies as they use for their desktop clients, and take full advantage of the facilities offered by the .NET platform.


The Windows CE Family

Part of Microsoft’s Windows Embedded Family, Windows CE is a 32-bit operating system with real-time processing support, including timer accuracy of 1 millisecond, support for nested interrupts and 256 levels of priority. The operating system runs on a wide range of processors, including ARM, MIPS and SH-based architectures, and is modular in design, which means you can choose just the components you need for a particular device.
      In the case of the Pocket PC and Smartphone, Microsoft has defined the platform and created the supporting SDKs for you. However you can use the Windows CE Platform Builder to configure the operating system and create the SDK for your own custom hardware. Once you have done this you can distribute the SDK to developers so they can write applications for your device. Platform Builder 3.0 supports Windows CE 3.0 and comes with eMbedded Visual Tools 3.0. Platform Builder 4.0 supports Windows CE .NET.
      Windows CE 3.0 includes support for COM and DCOM, Microsoft Message Queue, ActiveX Data Objects (ADOCE), XML and Microsoft Foundation Classes (MFC). It also includes the runtimes for eVB 3.0 and eVC++ 3.0. The Windows CE 3.0 Add-On Pack adds support for DirectX and Windows Media.
      Windows CE .NET 4.1 and 4.2 include the .NET Compact Framework, but will only run on processors based on the ARM architecture. They also support fibers (as introduced with Windows XP), and have a number of new features that allow applications to make better use of memory. Windows CE .NET adds supports catch/throw exception handling, and the COM subsystem has been rewritten to improve stability.
      Other additions include support for Bluetooth and 802.11, Secure Digital (SD) and MultiMediaCard (MMC), Object Exchange (OBEX) protocol for efficient exchange of data, Universal Plug and Play (UPnP), IEEE 1394, LDAP, Active Template Library (ATL) and Windows Messenger. Windows CE .NET 4.2 adds zero-configuration Wi-Fi support (similar to that found in Windows XP) and an accessible certificate store that enables PKI applications such as 802.1x.


Platform specifications

Pocket PC 2003
Pocket PC 2003 is a configuration of Windows CE 4.2 with extensions specifically targeted at pocket-sized devices where input is through a stylus, rather than a keyboard. The original Pocket PC platform was introduced in 2000 and has since been superseded by Pocket PC 2002 and 2003. Requirements include:

Pocket PC 2002 Phone Edition added data and voice applications for triple-band wireless connectivity through GSM and GPRS.

Smartphone 2003
Microsoft’s Smartphone 2003 platform is also based on Windows CE 4.2 but is aimed at devices modelled on the mobile phone. The original Smartphone 2002 specification did not support .NET Compact Framework, however this is supported by Smartphone 2003. Requirements include:

Send to a friend

Top of page

Click here for our Privacy Statement. Copyright © Matt Publishing. All rights reserved. No part of this site may be reproduced without the prior consent of the copyright holder.

Send to a friend

The ASP.NET approach

The Managed approach

Native Code applications

Making your choice

The Windows CE family

The Pocket PC 2003 specification

The Smartphone 2003 specification