Getting Started with the Smart Device Extensions
Let's begin by creating a new SDE application. Make sure you have the latest Visual Studio .NET 2003 installed, Professional Edition or higher, and that you have selected support for mobile development under either Visual Basic .NET or Visual C# .NET during setup. While all the precepts presented here and in future issues apply to both Visual Basic .NET and Visual C# .NET, being the veteran VB guy that I am I'll stick to the former in all my samples.
Create a new project, select the Smart Device Application
template under the Visual Basic .NET branch and name it MobileCoDeSDEApp
. Once you accept these options, you are presented with another window and it is... you've guessed it... a wizard! More specifically the Smart Device Application Wizard
. Don't gasp or expect too much though, this is merely a popup asking you to choose two options: the targeted platform, and the mobile project type you want to create.
Selecting Windows CE would mean targeting a generic Windows CE .NET 4.1 device, but since these devices are still fairly rare, we'll opt for Pocket PC support, which is probably what you are most familiar with if you own a Microsoft Pocket PC 2002 device such as an iPaq, a Dell Axim, a Toshiba e740, or some other compatible device. If you do not own a device, you needn't worry; the SDE features a choice of powerful smart device emulators for you to test with. In fact, choosing a target platform in this window configures your SDE project to use the proper emulator for when you eventually deploy and test your mobile application. Select Pocket PC as the platform for now. Future articles will focus on Windows CE .NET if you're interested in this next-generation Windows-Powered platform.
The second option you must select in this wizard is the project type. Just like in standard .NET Framework applications, SDE projects can be used to create many types of applications. There are naturally fewer options, especially since all server-side ASP.NET-based applications, including Web Forms and XML Web services projects, do not exist in the world of the .NET Compact Framework.
You can either create your whole project from scratch using the Empty Project template or you can create applications without any graphical user interface (GUI) using the Non-Graphical Application option. This latter option differs depending on the targeted platform. On the Pocket PC, it means the application is invisible and cannot display text or capture user input. This is because the notion of a console doesn't exist in that variant of the OS. If you target Windows CE.NET (feel free to try selecting it to see the difference), that option is replaced by a Console Application list item to select from. This should then be familiar territory for console application developers on the desktop. Don't be fooled, because the Console object does exist and work (i.e. no exceptions thrown) in the .NET Compact Framework, even in Pocket PC projects, but its ReadLine, Write and WriteLine members are useless in such a case.
|All server-side ASP.NET-based applications, including Web Forms and XML Web services projects, do not exist in the world of the .NET Compact Framework.|
The two options you are most likely to use are the Windows Application
and Class Library
project types. Provided you stick to the bounds of .NET Compact Framework classes, class libraries work in pretty much the same way as their desktop of server counterparts. These are in-process .NET assemblies (.dll) that run within the same application domain as the calling assembly (.exe), and their usage within a client application architecture follows the same rules you are already familiar with. Let's pick the Windows Application
project type, which is a standard .NET assembly compiled as an IL (Intermediate Language) portable executable (.exe), since we want to design a Pocket PC application that sports a form-based GUI.
Once you accept these settings, Visual Studio .NET and the SDE proceed to creating a basic Pocket PC application project that is ready for device deployment. The SDE features a Windows Forms designer very similar to the one used in standard Windows Forms projects. You'll notice the form is automatically sized to the proper Pocket PC screen dimensions and even though you can resize the form, you should leave it as it is to ensure that your application interface covers the whole display area.
Before adding controls and code to our new mobile application, I want to make sure we cover the basics of the SDE and .NET Compact Framework features. Jumping in blindly can be fun at times, but understanding the development mechanisms and the underlying architecture of this mobile framework is too important to ignore. Don't forget: RAD stands for Rapid, not Reckless Application Development.