In-Depth

Device Development 101

Get your system ready for device development and build a device application.

In my last column, I discussed changes to Microsoft's device development space as well as the releases of SQL Server 2005 Mobile Edition and the .NET Compact Framework. However, with respect to those of you who are new to device development, I will postpone our jump into these new technologies until you have a firm foundation under your feet. Instead, in this column, I will provide an overview of what you need to add to your system to be ready for device development. Once your system is ready, I will walk you through development of your first device application. So buckle up and here we go!

The first program you need to install is Visual Studio 2005 Professional Edition or a more feature-rich version. (The Visual Studio Express Editions do not support device development.) Taking it one step further, for Windows Mobile 6 development, you must also have the Service Pack 1 (SP1) for Visual Studio. Another set of service packs that you need are .NET Compact Framework SP1 and Service Pack 2 (SP2).

You must install the Developer Resource Kit for Windows Mobile 5 or 6. These resource kits provide you with the device emulator skins for the corresponding version as well as sample code and tools. For example, the resource kit for Windows Mobile 6 includes the utilities, such as FakeGPS and Cellular Emulator. Lastly, you must have ActiveSync 4.5 or a more recent version on your system.

When installing Windows Mobile 6 SDK, the program installer will identify any missing service packs or software that must be installed before giving you the option to continue. I ran across a minor installation problem when installing this SDK. I kept receiving an error dialog that said Visual Studio SP1 was not installed on my system, but I had already installed it. Thinking the worst, I rebuilt a secondary dev box from scratch, dutifully installing all of the components mentioned above, and I still received the same error dialog. So, I went ahead and installed Windows Mobile 6 SDK, and so far — cross your fingers — it works fine.

Create your first device application as you would any "normal" .NET application. Begin a new project and select Device Application from the list of project types (see Figure 1). You will see two project types: one is for Windows Mobile 2003, and the other is for Windows Mobile 5 or Mobile 6.

For this application, I've selected the Windows Mobile 5 option. The initial emulator/device target and the device's appearance in the form designer are different in the later versions of Windows Mobile. Figure 2 shows the designer for a Windows Mobile 5 application.

To change the target device to Windows Mobile 6, right-click on the project in Solution Explorer and select Change Target Platform. Figure 3 shows the IDE after this change. Notice that the target platform looks different in the combo box, but the default form designer skin looks the same.

You use the same build process for a device application as you use for a desktop application. Drag items from the toolbox to the design surface and add code behind the controls.

Once you finish building your device application, you need to run it. But unlike a desktop application, a device app requires an emulator or a device to run. You can use the Device toolbar shown in Figure 4 to setup your target device. The two buttons located on the far right-side of the toolbar rotate the form designer in clockwise or counter-clockwise directions. The button closest to the Target Device drop-down menu on the tool bar is used to connect to the device. If your target is an emulator, then the emulator will start; and if your target is a device, than a connection will be established. The button to the right of the Connect to Device button lets you set up the device or emulator. Figures 5 and 6 show the options for device setup with an emulator. For this application, use the defaults. I will explain the options in detail in my next few columns.

After you finish creating your first device application, explore the choices available to device developers. Experiment with different controls on the drop-down menu, write some sample code, and get familiar with the device setup options.

About the Author
Dan Fergus is the principal technologist at Forest Software Group, which provides consulting and contracting services to companies throughout the U.S. He is a Device Application Development MVP, a trainer, and the co-author of The Definitive Guide to the .NET Compact Framework. Fergus has also written many articles, is a frequent speaker at conferences and user groups, and is a contributing editor for Visual Studio Magazine. Contact him at [email protected].

About the Author

Dan Fergus is the chief architect at Forest Software Group, developing .NET applications, including Pocket PC sports team applications. He speaks at major conferences, does consulting, and teaches Compact Framework, VB.NET, and ASP.NET courses. He coauthored The Definitive Guide to the .NET Compact Framework (Apress). Reach him at [email protected].

comments powered by Disqus

Featured

Subscribe on YouTube