Getting Started with Building Windows Mobile Solutions with Visual Studio and Windows Mobile 6 SDK


Andrej Radinger, APPAMundi

April 2009


This article describes how to start to develop for Windows® phones by using the same tools that developers use for desktop development, Microsoft Visual Studio 2008, and the Windows Mobile specific Microsoft .NET Compact Framework 3.5. It also explains how to use Windows Mobile SDK Tools to extend Windows Mobile applications.

Windows Mobile 6 SDK downloads

Windows Mobile 6.1 Emulator Images download

Microsoft ActiveSync 4.5 download

Windows Mobile Device Center 6.1 (WMDC) download

Microsoft SQL Server Compact 3.5 SP 1 for Windows Mobile download

Microsoft .NET Compact Framework 3.5 Redistributable

Sample Application

Applies To

Microsoft Visual Studio 2005 and Visual Studio 2008

Windows Mobile 6

Windows Mobile 6 SDK Tools

Microsoft .NET Compact Framework 3.5


Visual Studio and .NET Compact Framework

Windows Mobile 6 SDK Tools

ActiveSync or Windows Mobile Device

Setup for the Development Environment

Developing your First Application

Deployment and Packaging

Advanced Features



This article focuses on how to develop Windows Mobile .NET Compact Framework offline client solutions. .NET Compact Framework (.NET CF) is a subset of the full Microsoft .NET Framework, with all the functionality that you must have to deliver powerful enterprise applications for the Windows Mobile platform. Visual Studio 2008 has built-in support for both the .NET Compact Framework 2.0 and .NET Compact Framework 3.5.

Visual Studio and .NET Compact Framework

Developers who develop desktop applications that use Visual Studio have all the necessary tools and knowledge to develop solutions for Windows Mobile platform. Of course, there are differences between the desktop and mobile platform, and you have to approach each differently. However, the programming concepts remain the same.

You have to answer the following questions before you start to develop a Windows Mobile solution:

  • What development tools do you have and want to use?
  • What platform do you want to target, Smartphone or Pocket PC?
  • What version of the .NET Compact Framework do you want to use?

Answers to earlier questions influence the direction you take with your project and how you start it. Other business-related considerations can also influence your decisions:

  • Do you want to create offline or online solution?
  • How expensive is your connection?
  • Do you want touch screen functionality?
  • Are you targeting multiple form factors or a single platform?
  • What are your security requirements?

After you analyze and answer all these questions, you are ready to take the correct direction with the project. This paper focuses on how to develop Windows Mobile .NET Compact Framework offline client solutions.

Visual Studio

Visual Studio has supported Windows Mobile application development with various additions and SDKs since Visual Studio 5.0. With Visual Studio 2005, mobile development became an important part of the development platform, and desktop developers became mobile developers instantly.

Visual Studio 2005 included .NET CF 2.0, which was a major upgrade from the earlier version. Visual Studio 2005 supports development for .NET CF 1.0 and 2.0. Out of the box, it supports development for Smartphone 2003, Pocket PC 2003 SE, and Windows CE. You can easily add support for Windows Mobile 5.0 (Smartphone, Pocket PC, and Pocket PC Phone Edition) and Windows Mobile 6 (Standard, Classic, and Professional) by installing SDKs for these platforms. There are two SDKs for each version 5.0 and 6, one for Smartphone (Standard) and one for Pocket PC and PPC Phone Edition (Classic and Professional). SDKs include various tools that greatly improve your development experience, emulators, GPS, mobile operator emulator, and more.

Visual Studio 2008 brought some new features and functionalities, both in the IDE and in functionality. Out of the box, Visual Studio supports Windows Mobile 5.0 platform, but not Windows Mobile 6. For Windows Mobile 6 support, you have to install the required SDK, as mentioned earlier. Visual Studio 2008 supports development for .NET Compact Framework 2.0 and 3.5. The following list shows some new features in Visual Studio 2008:

  • Support for unit testing, in Visual Studio Developer Edition and Visual Studio Team Suite
  • Remote Performance Monitor
  • Device Security Manager, part of Visual Studio 2008 IDE
  • New Device Emulators and Device Emulator Manager 3.0
  • New and redesigned New Project Wizard for creating new Windows Mobile projects

The ability to work with earlier versions of .NET CF in both versions of Visual Studio gives you great flexibility to start using the latest development tools, without breaking compatibility with existing projects that were developed on a previous platform.

Your choice of development tools and the development platform might depend on what projects that you have in progress and any compatibility that you must keep with them.

.NET Compact Framework

As its name suggests, .NET CF is smaller than the .NET Framework, and in most parts, supplies a subset of the .NET Framework functionality. Therefore, most applications that you develop for .NET CF should run without any modifications on the desktop .NET Framework platform. There are two main reasons for reduced functionality in .NET CF, unsupported desktop features and limited storage space on mobile devices. The differences between .NET Framework and .NET Compact Framework are fully documented in Visual Studio Help. Some major functional differences between .NET Framework and .NET CF 2.0 are as follows:

  • .NET CF does not have built-in support for reading configuration files. For this functionality, use some external tools, such as Mobile Client Software Factory (MCSF), or the "smart device framework” part of OpenNetCF (OpenNETCF SDF).
  • ClickOnce is not supported.
  • .NET Framework remoting is not supported.
  • Binary serialization is not supported.
  • Printing is not supported.
  • Compared to .NET CF 1.0, .NET CF 2.0 provides improvements such as performance, compatibility with the .NET Framework, and Windows Forms controls. The following list shows some new controls that are added and improved:
    • MonthCalendar. New in .NET CF 2.0.
    • DataGrid. Greatly improved.
    • DateTimePicker. New in .NET CF 2.0.
    • LinkLabel. New in .NET CF 2.0.
    • Splitter. New in .NET CF 2.0.
    • WebBrowser. New in .NET CF 2.0.

Because Visual Studio 2005 and 2008 support application development for various resolutions and various orientations, .NET CF 2.0 introduced some major improvements in display and layout management. When you change Orientation from Portrait to Landscape or vice versa, you want your application and interface to remain fully functional and available. To support that requirement, the following improvements were made in .NET CF 2.0:

  • Support for docking and anchoring.
  • Automatic scrollbars. If because of an orientation change, some controls remain outside the visible area, horizontal and vertical scrollbars are created automatically to provide access to all parts of user interface.
  • Tab order support. Enables moving from one control to another by using the TAB key.

Working with data in .NET CF 2.0 resembles working with data in the .NET Framework. ADO.NET is almost fully supported. Working with Microsoft SQL Server Compact Edition (various versions), and working with XML, Web services, and files as data stores is supported. .NET CF supports datasets, data binding, and collections. It also introduces SqlCeResultSet, a new way to access and managing data in applications that use SQL Server CE as a data store. SqlCeResultSet represents a combination between a dataset and data reader. It can be defined as an updatable and scrollable data reader and, compared to a dataset, it provides optimized access to a SQL Server CE database.

.NET Compact Framework 3.5 is a superset of .NET CF 2.0, supporting the same platform and functionality as in .NET CF 2.0. It also adds some new functionality to improve the developer and user experience:

  • Support for Windows Communication Foundation (WCF)
  • Support for compact LINQ (Language Integrated Query)
  • Support for client certificates to authenticate Web services calls
  • Various new APIs
  • Debugging improvements

Windows Mobile 6 SDK Tools

Windows Mobile 6 SDK Tools are an addition to Visual Studio and .NET CF. They provide support and templates for developing applications targeting Windows Mobile 6 platforms. They also include useful tools that help develop and test applications without any need for real devices and infrastructure. Windows Mobile 6 SDK Tools are free downloads. They require you to have Visual Studio 2005 or 2008 and .NET CF installed. There are two separate installations for two platforms. One is Windows Mobile 6 Standard (previously called Smartphone) and the other one is Windows Mobile 6 Professional, targeted for both Classic (previously called Pocket PC) and Professional (previously called Pocket PC Phone Edition).

Device Emulator Manager

Device Emulator Manager manages Device Emulators that are installed on the developer workstation. On Device Emulator Manager, you can perform the following actions:

  • Start the Device Emulator
  • Restart the Device Emulator
  • Shut down the Device Emulator
  • Cradle a previously started Device Emulator. In order to use this functionality, you must have installed Microsoft ActiveSync® 4.5 on Windows XP or Windows Mobile Device Center (WMDC) on Windows Vista®. It lets you simulate a real-life environment, and test applications for the production environment. Because many applications check for ActiveSync connectivity and act accordingly, this is a great tool. It enables you to test it on the Device Emulator.
  • Uncradle a cradled Device Emulator
  • Use the Save As functionality that enables you to save different states of the same emulator. By default, you can only save one state for each emulator. However, this enables you to save different states and to reuse them when it is necessary. Saved emulators can be accessed from My Device Emulators.

You can access Device Emulator Manager on the Windows Mobile 6 menu from Windows or from Visual Studio IDE.


Windows Mobile Device Emulators

Visual Studio includes emulators for platforms supported out of the box. SDKs provide emulators for other platforms, supported by that specific SDK. Device Emulators are very helpful in development and the debugging and testing process because you do not have to have devices, but do it all on a development workstation. Also, if there is a team of developers, there is no need for each developer to have a device. In a team environment, it is very helpful to set up a required environment in the emulator and to distribute it to all developers in the team.

Device Emulators are based on an ARM processor, and they give the appearance of real devices. Nevertheless, we strongly recommend always testing the completed solution on a physical device with real hardware, before going live.

You can start the Device Emulator from Microsoft Visual Studio IDE, manually or automatically when you deploy the application, or from Device Emulator Manager as previously mentioned. When it is up and running, you can configure it to meet your needs. You can access configuration options on the Device Emulator menu.


Accessing a Host File System

You frequently have to access host files and folders from the Device Emulator. The following illustration shows how to set up the location of a Shared folder in the Emulator configuration.


That gives you access to that folder from the Device Emulator. The Shared folder is displayed as a Storage Card in the Emulator File Explorer.


Networking from the Device Emulator

To simulate real-world environment, sometimes you must have a network connection in the Device Emulator. To do that, you have to set up the host network adapter that you want to connect to in the emulator.


After the network adapter is set up, you have to set up the network adapter in the emulator (Start/Settings/Connections/Network Cards/NE2000 Compatible Ethernet Driver).


When everything is set up correctly, the emulator should have access to the host network resource and the Internet.

You can also establish a connection with the host computer, by using ActiveSync or Windows Mobile Device Center, as described later in the document.

Cellular Emulator

Cellular Emulator is part of Windows Mobile 6 SDK Tool. It emulates the presence of mobile operator network that enables developers to test phone functionality in their applications from a Device Emulator. To configure Cellular Emulator to communicate with Device Emulator, you have to map its COM port to the physical port of Device Emulator.


When it is run and configured, the Cellular Emulator enables Windows Mobile 6 Professional Device Emulator to send and receive phone calls and SMS messages, and data services, such as GPRS and 3G.


Fake GPS

As its name suggests, Fake GPS enables you to use GPS functionalities from Device Emulators or physical devices that do not have GPS, or to test applications in scenarios where you do not have GPS coverage. You have to examine both, support for GPS and Fake GPS itself. As you will see later in the sample application, use the Microsoft.WindowsMobile.Samples.Location namespace and assembly to access GPS functionality. To receive access to that assembly, you have to open GPS sample solution that includes SDK Tools in Visual Studio and build it. It creates the required assembly for use in all applications that use GPS. That assembly is necessary to use GPS (even though it is not the only option).

Fake GPS is a small application that you have to install with Device Emulator. When it is enabled, it runs like a service on the emulator. It randomly provides GPS coordinates from one of the files that are included to applications that use the assembly. The application behaves the same way it will with a physical GPS on a device and reads real GPS coordinates from a GPS device.


Other Windows Mobile 6 SDK Tools

In addition to tools that were mentioned earlier, SDK Tools have some additional tools that are not used or discussed in this article. The Fake server simulates presence of a real physical network without ever leaving Device Emulator. Hopper is another tool that simulates random keystrokes and taps on the device or emulator. This provides an excellent input stress test.

ActiveSync or Windows Mobile Device Center

The emulator can access host resources (file system, Internet, Web services, WCF services, databases) if you correctly set up network connection properties on both, the host computer and Device Emulator. Another approach that seems to be easier and more intuitive for users is cradling, connecting Device Emulator to ActiveSync or WMDC for full access to host resources.

Microsoft ActiveSync 4.5 and its latest updates is a tool that has to be installed separately on Windows XP. It should be used for the Windows Mobile 6 platform. It enables you to create a partnership between the device (emulator) and the host computer and defines what you do when you want to synchronize (Microsoft Office Outlook items, files, custom applications). You can also use it to access the device (emulator) file system from Windows Explorer on the host computer and to transfer data back and forth.

WMDC is the ActiveSync replacement in Windows Vista, because ActiveSync is not supported in Windows Vista. The user interface and architecture are improved. However, the basic purpose remains the same.

Windows Mobile devices and Device Emulators have ActiveSync built into the OS.


Setup for the Development Environment

You are now familiar with tools that you must have to develop Windows Mobile 6 solutions and surrounding environment. You have to install the following software products and tools to your development environment in order to get started:

  1. Visual Studio 2005 or 2008
  2. Latest Visual Studio, .NET Framework and .NET Compact Framework updates
  3. Windows Mobile 6 SDK Tools Standard or Professional, or both
  4. Latest emulators to be supported, not included in SDK Tools
  5. ActiveSync (on Windows XP) or Windows Mobile Device Center (on Windows Vista)
  6. SQL Server CE 3.5 SP1 (and available updates) to work with local data stores

You are now ready to start and develop your first Windows Mobile solution.

Developing your First Application

To start a mobile project, follow the same procedure as when you are developing standard desktop application. In Visual Studio, create a new project, select the language, and then select the Smart Device project template. Also select other project properties, such as name and location.


The next step is specific to Windows Mobile solutions. You have to define the target platform and version of the .NET Compact Framework. As mentioned earlier, in Visual Studio 2005, you can target .NET CF 1.0 and 2.0, and in Visual Studio 2008, you can target .NET CF 2.0 and 3.5. As a target platform, you can select any platform available on the developer workstation: Windows Mobile 5.0 or 6, or Windows CE, or even Pocket PC 2003.


Now you have a regular Visual Studio solution with a basic application skeleton. Also notice that Form1 is enclosed in the device skin. It simulates a real application environment. The skin can be disabled in Visual Studio IDE on the form itself. Visual Studio IDE looks familiar, with all standard elements, such as the toolbar, Solution Explorer, Properties, Form Designer, Code Editor, and more. There is also a toolbar specific to Windows Mobile solutions, where you can select the target device and emulator, connect to the device and emulator, set various device options, and change rotation in Form Designer from Portrait to Landscape or vice versa.


.NET Compact Framework is a subset of the .NET Framework and so is the set of supported controls and their properties. Core development and user interface design is the same as Windows desktop application development and is not covered by this article.

Creating the User Interface

When you design the user interface for mobile devices, you have to be aware of the limitations of the small form factor, and design the user interface accordingly. It is never good practice to copy the user interface from a desktop application to a mobile device. One of the approaches that is very common in desktop applications, scrolling, is bad practice on mobile devices. It is very user unfriendly to scroll up and down on a mobile device and should be avoided when it is possible. Instead, use different approaches for that, such as Tab controls, panels, or similar approaches.

Menus on Windows Mobile Devices are located on the bottom of the screen. They are created in the same manner as menus in desktop applications. However, it is good practice not to nest them more than three levels down, because they become unreadable after that. Mobile forms allow for two menu items that correspond to a left and a right soft key, Soft Key 1 and Soft Key 2. They can have nested menus as necessary. It is common practice to put the default action on the left soft key, and all actions and nested menus on the right soft key.

Windows Mobile 6 devices support orientation change. Therefore, applications that are written for a certain orientation become user unfriendly when the orientation is changed. Automatic scroll bars are supported, but as mentioned earlier, scrolling should be avoided when possible. Using docking and anchoring (supported from .NET CF 2.0) provides a solution in most cases and should be used when applicable.

Controls available in .NET CF are all standard controls (text box, label, common dialog boxes, tab, grid, and more) plus many advanced controls (Web browser) from the .NET Framework.

In Windows Mobile forms, the X in the upper-right corner means minimize the window, instead of closing it. To close it, you have to set the MinimizeBox property of the form to False. Then ok appears that means close the window.


Handling Input

Compared to standard desktop input methods, keyboard and mouse, mobile devices handle input somewhat differently. Keyboard became a standard option in many mobile devices so that users can use it as an input device for mobile devices, but more common options are Taps, Software Input Panel (SIP), and Hardware keys.

Tap is to a mobile device, what the left mouse double-click is to the desktop. It is a common input method on touch-screen devices. Tap-and-hold corresponds to right-click. It opens the shortcut menu for selected items. When tap is used on a control in a Windows form, it starts all corresponding events for that control: MouseDown, MouseUp, MouseMove, Click, DoubleClick. From a programmatic perspective, it is the equivalent to a mouse click, and you can handle all these events in your application just as you handle them in desktop applications.

The soft input panel lets users accept keyboard input without a physical keyboard. SIP in combination with Tap provides a real keyboarding experience for users, invoking events associated with pressing keys on the keyboard: KeyUp, KeyDown, and KeyPress.


The Input panel is a .NET CF control, and when you add it to the form, it can be programmatically controlled from the code. You can see it when the text box control receives the focus:

inputPanel1.Enabled = true;

and close it when the control loses the focus:

inputPanel1.Enabled = false;

Error Handling and Debugging

Error handling in .NET CF is performed exactly like in the .NET Framework, by using a try….catch….finally structure. Microsoft Visual Basic also supports On Error GoTo andResume [Next] for error handling, but try….catch… finallyblocks are preferred because they are less resource intensive. Standard managed debugging is also supported in .NET CF in similar ways as in the .NET Framework. Deploying and debugging applications is supported on both devices and emulators.

Starting with .NET Compact Framework 3.5, unit testing is also supported for Windows Mobile projects.

Working with Data

.NET CF supports working with various data sources. The concept is the same as the .NET Framework and most important, ADO.NET is supported in most of its functionality. Windows Mobile applications can use SQL Server CE, XML, SQL Server, Web services, or WCF service as data sources.

XML is a common format that most data sources can export data to, and import data from. Even though it can be used by most data sources, we do not recommend it as a data store, because it has a large overhead, it is not optimized, and is much slower than a relational database, because it has no indexes. However, if there is no other option, XML can be used as a data store on the device.

SQL Server can directly be accessed from devices as a data store. It is a great concept if there is no need for an offline solution. If you can guarantee a constant connection, use it. It will keep data on the server up-to-date in real time, and reduce possibility of conflicts. Warehouses are a good example of an environment where this approach is acceptable, even desirable.

Web Services and WCF service are a good choice for transferring data in the n-tier environment when you do not have direct access to SQL Server (either for direct data access or for replication). In this scenario, the data source can be anything, and the local data store can be anything acceptable to .NET CF.

SQL Server Compact Edition

SQL Server CE is the best and most optimized data store in mobile solutions. It is only a data store (only has tables, nothing else). However, it has everything related to tables, indexes, primary and foreign keys, referential integrity, and constraints. It does not have triggers, because no programmability is supported in SQL Server CE. In addition to being RDBM, SQL Server CE has another big advantage. It can be used as a replication subscriber in SQL replication that makes it a perfect companion to SQL Server. It is very easy to control replication programmatically, and all conflicts are handled centrally by the administrator.

To add a new data source to a Windows Mobile project, follow the same procedure as with the .NET Framework, by using the same wizard. You have to select Microsoft SQL Server Compact Edition 3.x as a data source and also select a database. SQL Server CE databases have the .sdf extension. Select a database from a local disk, or from the device that is connected through ActiveSync or WMDC.


Because you are using SQL Server CE as the local data store, during deployment the database is copied to the device. Therefore, the connection string that was created when you selected a database in the previous step will not be valid on the device. The wizard will ask whether you want to change the connection string so that it always points to the application folder on the device.


Data Binding

As soon as the database is added to the project, you can use standard ADO.NET to work with it. You can bind controls to the data source by using the Data Binding object or binding directly to the data source. To work with data on the device, you can use standard datasets. The problem with a dataset on a mobile device is that you are creating a copy of data in-memory that resides on the device anyway. That approach is causing unnecessary resource usage and performance overhead. To avoid it, use the object that is specific to the SQL Server CE data adapter, SqlCeResultset. It is an optimized, updatable, and scrollable cursor which accesses SQL Server CE data directly from the application, without any need for a dataset. We recommend it for working with SQL Server CE data on the device.

To work with SQL Server CE data on the device, you have to add a reference to the System.Data.SqlServerCe namespace in the project.

The following code example shows how to define the reference in the code, and to create and use SqlCeResultset.

using System.Data.SqlServerCe;
SqlCeResultSet rs;
SqlCeCommand cmd = new SqlCeCommand(command text, sql ce connection);
rs = cmd.ExecuteResultSet(ResultSetOptions.Scrollable);
control.DataSource = rs;

Deployment and Packaging

The last step in the project development cycle is to deploy the completed solution to the device and to package it for distribution and mass deployment. There are several ways with which an application can be deployed to the device or emulator: Development IDE deployment, Device Installer, or Desktop Installer. This article describes the first two options.

Development IDE Installer

The easiest way to deploy the application is when the device is connected to the development workstation through ActiveSync or WMDC. It is also how you deploy applications during development and debugging.

The first step is to select the deployment device or emulator.


When you select it, you can connect to the target device manually from the toolbar or the deployment process connects automatically if it is not connected already.

To start a deployment process, use the regular deployment procedure, F5 or Start on the Debug menu. You are asked to confirm the target device or emulator (the confirmation box can be disabled) and the deployment process starts. Visual Studio first checks whether all components that are required to run the application are installed on the target device. If not, they will be installed on the first run. .NET Compact Framework is a necessary component, and others might be SQL Server CE or any other component which is not part of .NET CF and is used by the application. The following illustration shows the component currently installed and its progress in the Status bar at the bottom of the Visual Studio project window.


This is a reliable way that everything required for the application to work correctly will be installed on the device or emulator. It is also the fastest way, assuming that the device is connected to the development workstation.

Device Installer

It is not very likely that every device that is used in production arrives at the developer's desk for application deployment. There is no need for that and it also does not resolve the problem of future updates. Device Installer is the method that enables applications to be easily deployed directly on the device, without any need for a connection between the device and the developer workstation. All assemblies and dependencies are packed in a single (or more) CAB file which is copied to the device and executed there. The CAB execution on the device installs it with predefined parameters. The CAB file can be distributed through e-mail, a Web server, external cards, or by coping it through ActiveSync or WMDC.

In the Add New Project dialog box, under Templates, there is a project template in Visual Studio to enables you to create CAB projects. The illustration shows the location.


In the CAB project, you have to define project output, which is the application that you just finished.


After the project output is set, it is automatically added to the application folder for installation. You can do various things in the deployment project, such as creating shortcuts for project output to appear in Programs or on the Start menu.


On the File System tab, you have access to various system folders, and you have the freedom to put files anywhere you want. Then, you have access to the Global Assembly Cache (GAC), Program Files, Windows, Startup, and Fonts. You can also have more than one Output folder if it is necessary.

Through the Deployment project, you can also alter registry settings and add new keys for your application.


Even though it is good practice to distribute and install dependencies (.NET CF, SQL Server CE) separately to keep the CAB file as small as possible, you can also include dependencies into the final CAB. By default, they are excluded. The illustration shows that you can also include them in the Deployment project.


When all parameters for the Deployment project are set, you can build it. The result of the building action is a redistributable, self-executing CAB file, ready to be distributed and deployed directly on devices.

Advanced Features

The earlier sections covered basic mobile application development and steps associated with it. The following section covers some more advanced development features that can greatly improve application functionality and the user experience.

Pocket Outlook Object Model (POOM) Integration

The POOM API is part of the Microsoft.WindowsMobile.PocketOutlook library. Through POOM, you can access Calendar, Contacts and Tasks on the device. All activities that use POOM functionality are based on the OutlookSession class. Therefore, in your applications, you must always have an instance of that object at the application level.

The following code example shows that an OutlookSession object is declared the first time that it appears and that an instance of it is created.

using Microsoft.WindowsMobile.PocketOutlook;
namespace WP_FirstApp
    public partial class Form1 : Form
        private OutlookSession outlook;

        private void Main_Load(object sender, EventArgs e)
            outlook = new OutlookSession();

After the Outlook session object is created and an instance of the object is created, you use it for all activities related to Outlook objects and collections.

The following code example shows that it is very easy to create a new task from the application.

                Task task = new Task();
                task.Subject = textBox1.text;
                task.Body = textBox2.text;

New task will be added to Pocket Outlook Tasks, and can be managed either from code or from Tasks directly. Existing tasks can also be altered from the application.

You can also manage Contacts from the application, using the same parent object as for Tasks. When you create a new contact, all fields are optional. However, some basic set of information should be set, to recognize the contact later. The following code example shows the code for creating a new contact.

                Contact con = outlook.Contacts.Items.AddNew();
                Con.FirstName = textBox1.text;
                Con.LastName = textBox2.text;

To select an existing contact, use the ChooseContactDialog object. This object can be used to access a specific contact or a specific property of a contact. ChooseContactDialog enables you to filter contacts to be shown to the user, by using the RestrictContacts property and setting the filter. Contacts can be filtered by any field from the Contacts/Items collection.

The following code example shows how to use an instance of the ChooseContactDialog class to present a Contacts dialog box to the user and how to retrieve the business telephone number of the contact if a contact was selected by the user from the dialog box.

                ChooseContactDialog dialog = new ChooseContactDialog();
                dialog.RestrictContacts = "[Department] = \"Field\"";
                dialog.Title = "Assign To";

                if (dialog.ShowDialog() == DialogResult.OK)
str = dialog.SelectedContact.BusinessTelephoneNumber;

If a set of properties that are defined for the collection of Tasks, Calendar or Contacts does not fulfill user needs, you can create Custom Properties. Custom properties are not synchronized through ActiveSync and they cannot be accessed through Pocket Outlook.


Messaging refers to e-mail and Short Message Service (SMS) messages.


E-mail functionality is accessed through the EmailMessage object. The EmailMessage object contains all standard properties that e-mail messages usually have: Attachments, Bcc, BodyText, CC, Importance, Subject, To, and more.

The following code example show how to create a new e-mail message, set properties, and send an e-mail message to the contact previously selected.

EmailMessage email = new EmailMessage();
email.To.Add(new Recipient(dialog.SelectedContact.Email1Address));
email.Subject = textBox1.text;
email.BodyText = textBox2.text;

This code puts your message into the Outbox, until the user explicitly synchronizes. You can also force synchronization programmatically by using the Synchronize method.


Handling SMS resembles handling e-mail. Except for having fewer properties, the main difference is that when it calls a Send method, an SMS message is sent immediately, whereas an e-mail message waits for the next synchronization.

The following code example shows how to create a new SMS message and send it.

          SmsMessage sms = new SmsMessage();
          sms.To.Add(new Recipient("123456"));
          sms.Body = "WP_FirstApp SMS message";

SMS Interception

SMS messages can easily be intercepted by the application by using the MessageInterceptor object. The MessageInterceptor object is contained in the Microsoft.WindowsMobile.PocketOutlook.MessageInterception namespace. Messages to be intercepted can be filtered by the message body, the message subject or sender. Using SMS as a messaging transport enables input data into the application without actually having a user to enter data manually. SMS Interception can be used even if the application is currently not running.

The following example code shows how to implement SMS interception.

// SMS Interception Setup
smsInterceptor = new 
      smsInterceptor.MessageCondition = new MessageCondition(
      smsInterceptor.MessageReceived += new 

// SMS Interception event handler
private void smsInterceptor_MessageReceived(object sender, 
MessageInterceptorEventArgs e
if (e.Message.GetType() == typeof(SmsMessage))
SmsMessage message = (SmsMessage)e.Message;
//do something with message


Making voice calls from applications enables you to use phone functionality directly from the application, without having to go to a device dialer. The Phone class is in the Microsoft.WindowsMobile.Telephony library. Use the Phone class to establish voice calls. The following example code shows how to establish voice calls by using the contact that you previously selected.

using Microsoft.WindowsMobile.Telephony;

private void MakeVoiceCall()
            Phone phone = new Phone();


Developing for the Windows Mobile platform is no more difficult than developing desktop applications. Many of the same tools and techniques apply but there are significant differences between .NET Compact Framework and the .NET Framework. Most of the classes and controls in the .NET Framework are supported in the .NET CF though some have functionality customized for the needs and restrictions of the mobile device.

To add value to mobile solutions, you frequently add functionalities specific to the mobile device, such as POOM integration, telephony integration, GPS and various other programs. Windows Mobile 6 development with Visual Studio requires installation of the Windows Mobile 6 SDK. The SDK includes Device Emulators and other tools that bring unique aspects of the mobile environment, such as POOM integration, GPS, and mobile telephony into the development environment without requiring access to physical devices.

One of the most important factors to understand when you are developing for Windows Mobile is that mobile device display size, memory available, processor power, and external additions are very limited. Consider those when architecting your applications, in order to achieve the best possible performance and user experience. All required tools to achieve that goal are available. You just have to use them efficiently.

Author Bio

Andrej Radinger is a Microsoft Device Application Development MVP for Mobile Devices, MCSD, MCDBA and MCT. Andrej is a cofounder of APPAMundi, a company focused on implementing Mobile Solutions in the enterprise environment. Andrej has over 13 years of experience as a developer, trainer, and consultant, with over ten years of experience working on all aspects of mobility. He is focused on Microsoft technology. He is also a Technology Champ for a mobility user group and local newsgroup and a regular speaker at Microsoft events in the EMEA region. This includes Tech·Ed.

Andrej can be contacted at

Additional Information

Differences between .NET FX and .NET CF

One of the best sites to start, for access to many code samples, white papers, downloads, documentation, and blogs, see this Microsoft site on MSDN.

One of the most complete books covering mobile development is the Microsoft Mobile Development Handbook.

See Also

Other Resources