Welcome!

Mobile IoT Authors: Elizabeth White, Dean Madison, Yeshim Deniz, Shelly Palmer, Liz McMillan

Related Topics: Mobile IoT

Mobile IoT: Article

Getting Started with the .NET Compact Framework

Getting Started with the .NET Compact Framework

The .NET Compact Framework is a managed execution environment (a runtime engine) that runs on devices that use the Windows CE operating system - Pocket PC and Windows CE .NET devices. The runtime components also include a large collection of base class libraries that you use in your .NET applications to do everything from displaying UI on the screen to working with files to accessing network resources such as XML Web services. It's a slimmed-down version of the full .NET Framework that you might use to develop applications for servers and desktop PCs.

It does a similar job to Java 2, Micro Edition (J2ME), but the .NET Compact Framework is firmly targeted at higher-end PDAs and PDA- phone hybrids. It's too big to go on the kind of small phones that J2ME CLDC MIDP works on. It's definitely in the same space as J2ME in its CDC (Personal Java) configurations, though.

What Does It Run On?
The .NET Compact Framework currently runs on Windows CE devices only. You can use it with Pocket PC 2000 and Pocket PC 2002 devices, or custom handheld devices using the Windows CE .NET operating system. A version from Microsoft for their Smartphone is expected, although no announcements have been made.

However, it's not necessarily for Microsoft devices only. The specification of the CLR (Common Language Runtime - the runtime engine) is a published standard, so anyone can build one. Recent speculation has suggested that Palm will be supporting it in Palm OS 6.

How Do I Build Applications?
You write applications using Visual Basic .NET or C# using Microsoft Visual Studio .NET 2003. You'll need a PC running Windows 2000 or Windows XP, plus around 4GB of free disk space to run Visual Studio .NET. You can order a DVD containing a 60-day trial version of Visual Studio .NET at http://msdn.microsoft.com/vstudio/productinfo/trial/default.asp. You just have to pay the postage. This IDE provides you with everything you need, including Pocket PC 2002 and Windows CE .NET emulators, so you don't even need a real device.

Visual Studio .NET 2003 will be released in February or March 2003. Don't get the 2002 version - it doesn't support the .NET Compact Framework.

Building an Application
To get started, open Visual Studio .NET 2003 and click on File ->New Project. In the New Project window (see Figure 1), select either Visual Basic or Visual C# projects in the left pane according to your preference, then click the Smart Device Application icon in the right pane. Enter the name you want to give this project (for example, "MyFirstSmartDeviceApplication") and click OK.

Another window appears, this time asking you what kind of project you want, and which platform it should run on. Choose the Pocket PC platform, and the Windows Application project type. Click OK and Visual Studio .NET creates the project for you.

Using the GUI Designer
Now you're working in a familiar Visual Studio .NET drag-and-drop visual designer. You build your user interface by dragging controls from the Toolbox onto the Form. For this simple application, click on the Toolbox tab on the left edge of the screen so that it slides into view, then drag a label onto the Form (see Figure 2).

You can set properties of the control you just dragged on in the Properties window in the lower right corner of the screen. Set the Text property to a suitable value, such as "Hello, World" or perhaps something more original. Play with some of the other properties - click on the Form to select it, then change the Backcolor property, or set the Text of the Form to display a suitable heading on the Form.

One tip for Pocket PC applications: if you want to get the little "OK" icon on the taskbar at the head of your Form, set the MinimizeBox property of the Form to False. The OK icon is actually the "Quit" option for a Pocket PC application. If you don't do this, you just get an "X" icon, which actually means "minimize." (I know - "X" means minimize, whereas on a PC it means quit? Just don't ask - the Pocket PC user interface has been honed through several Microsoft failures in earlier versions, and users seem comfortable with it. This whole subject deserves its own article.)

Testing Your Application
When you're finished, click the Build menu, option Build Solution. If it builds successfully, click the Debug menu, option Start. You'll be asked where to deploy your application. If you have a real Pocket PC device connected to your desktop by a synchronization cradle, or by InfraRed or 802.11b, then you can select Pocket PC Device. Otherwise, choose the built-in Pocket PC 2002 emulator.

If the target device does not have the .NET Compact Framework runtime installed, Visual Studio .NET downloads it and installs it, along with your application. The emulator runs a true Pocket PC operating system in a virtual machine hosted by your desktop PC. The first time you use it, the .NET Compact Framework runtime must be installed into it, as shown in Figure 3.

New Pocket PC devices that come out in 2003 will have the .NET Compact Framework preinstalled, but on older devices you have to install it manually.

If everything has gone well, you'll see your application displayed on the screen of the emulator (see Figure 4).

Summary
You've created your first application. The .NET Compact Framework class libraries are extensive and allow you to create all kinds of sophisticated applications to run on handheld devices. There is an implementation of Windows Forms, which supports the majority of the controls that you can use in desktop applications with the full .NET Framework. There are also classes to allow you to write XML Web services client apps, and to work with SQL Server CE databases on the device, or fetch data from back-end SQL servers over HTTP or via wireless or wireline LAN.

It's an impressive product that allows the .NET developer to easily transfer skills learned with desktop applications to applications on smart devices. Have a go and see what you can do - I think you'll be impressed!

More Stories By Andy Wigley

Andy Wigley is a principal technologist at Content Master Ltd, focusing on mobility. He is the coauthor of Building ASP.NET Applications for Mobile Devices and .NET Compact Framework Developer's Core Reference, both published by Microsoft Press.

Comments (0)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


@ThingsExpo Stories
SYS-CON Events announced today that SIGMA Corporation will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. uLaser flow inspection device from the Japanese top share to Global Standard! Then, make the best use of data to flip to next page. For more information, visit http://www.sigma-k.co.jp/en/.
SYS-CON Events announced today that NetApp has been named “Bronze Sponsor” of SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. NetApp is the data authority for hybrid cloud. NetApp provides a full range of hybrid cloud data services that simplify management of applications and data across cloud and on-premises environments to accelerate digital transformation. Together with their partners, NetApp em...
Agile has finally jumped the technology shark, expanding outside the software world. Enterprises are now increasingly adopting Agile practices across their organizations in order to successfully navigate the disruptive waters that threaten to drown them. In our quest for establishing change as a core competency in our organizations, this business-centric notion of Agile is an essential component of Agile Digital Transformation. In the years since the publication of the Agile Manifesto, the conn...
There is huge complexity in implementing a successful digital business that requires efficient on-premise and cloud back-end infrastructure, IT and Internet of Things (IoT) data, analytics, Machine Learning, Artificial Intelligence (AI) and Digital Applications. In the data center alone, there are physical and virtual infrastructures, multiple operating systems, multiple applications and new and emerging business and technological paradigms such as cloud computing and XaaS. And then there are pe...
Real IoT production deployments running at scale are collecting sensor data from hundreds / thousands / millions of devices. The goal is to take business-critical actions on the real-time data and find insights from stored datasets. In his session at @ThingsExpo, John Walicki, Watson IoT Developer Advocate at IBM Cloud, will provide a fast-paced developer journey that follows the IoT sensor data from generation, to edge gateway, to edge analytics, to encryption, to the IBM Bluemix cloud, to Wa...
SYS-CON Events announced today that MIRAI Inc. will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. MIRAI Inc. are IT consultants from the public sector whose mission is to solve social issues by technology and innovation and to create a meaningful future for people.
While some developers care passionately about how data centers and clouds are architected, for most, it is only the end result that matters. To the majority of companies, technology exists to solve a business problem, and only delivers value when it is solving that problem. 2017 brings the mainstream adoption of containers for production workloads. In his session at 21st Cloud Expo, Ben McCormack, VP of Operations at Evernote, will discuss how data centers of the future will be managed, how th...
SYS-CON Events announced today that Keisoku Research Consultant Co. will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Keisoku Research Consultant, Co. offers research and consulting in a wide range of civil engineering-related fields from information construction to preservation of cultural properties. For more information, vi...
SYS-CON Events announced today that Fusic will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Fusic Co. provides mocks as virtual IoT devices. You can customize mocks, and get any amount of data at any time in your test. For more information, visit https://fusic.co.jp/english/.
SYS-CON Events announced today that Enroute Lab will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Enroute Lab is an industrial design, research and development company of unmanned robotic vehicle system. For more information, please visit http://elab.co.jp/.
SYS-CON Events announced today that Mobile Create USA will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Mobile Create USA Inc. is an MVNO-based business model that uses portable communication devices and cellular-based infrastructure in the development, sales, operation and mobile communications systems incorporating GPS capabi...
SYS-CON Events announced today that Interface Corporation will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Interface Corporation is a company developing, manufacturing and marketing high quality and wide variety of industrial computers and interface modules such as PCIs and PCI express. For more information, visit http://www.i...
SYS-CON Events announced today that Ryobi Systems will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Ryobi Systems Co., Ltd., as an information service company, specialized in business support for local governments and medical industry. We are challenging to achive the precision farming with AI. For more information, visit http:...
SYS-CON Events announced today that N3N will exhibit at SYS-CON's @ThingsExpo, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. N3N’s solutions increase the effectiveness of operations and control centers, increase the value of IoT investments, and facilitate real-time operational decision making. N3N enables operations teams with a four dimensional digital “big board” that consolidates real-time live video feeds alongside IoT sensor data a...
Internet of @ThingsExpo, taking place October 31 - November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA, is co-located with 21st Cloud Expo and will feature technical sessions from a rock star conference faculty and the leading industry players in the world. The Internet of Things (IoT) is the most profound change in personal and enterprise IT since the creation of the Worldwide Web more than 20 years ago. All major researchers estimate there will be tens of billions devic...
Mobile device usage has increased exponentially during the past several years, as consumers rely on handhelds for everything from news and weather to banking and purchases. What can we expect in the next few years? The way in which we interact with our devices will fundamentally change, as businesses leverage Artificial Intelligence. We already see this taking shape as businesses leverage AI for cost savings and customer responsiveness. This trend will continue, as AI is used for more sophistica...
SYS-CON Events announced today that SourceForge has been named “Media Sponsor” of SYS-CON's 21st International Cloud Expo, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. SourceForge is the largest, most trusted destination for Open Source Software development, collaboration, discovery and download on the web serving over 32 million viewers, 150 million downloads and over 460,000 active development projects each and every month.
SYS-CON Events announced today that mruby Forum will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. mruby is the lightweight implementation of the Ruby language. We introduce mruby and the mruby IoT framework that enhances development productivity. For more information, visit http://forum.mruby.org/.
In his session at @ThingsExpo, Greg Gorman is the Director, IoT Developer Ecosystem, Watson IoT, will provide a short tutorial on Node-RED, a Node.js-based programming tool for wiring together hardware devices, APIs and online services in new and interesting ways. It provides a browser-based editor that makes it easy to wire together flows using a wide range of nodes in the palette that can be deployed to its runtime in a single-click. There is a large library of contributed nodes that help so...
What is the best strategy for selecting the right offshore company for your business? In his session at 21st Cloud Expo, Alan Winters, U.S. Head of Business Development at MobiDev, will discuss the things to look for - positive and negative - in evaluating your options. He will also discuss how to maximize productivity with your offshore developers. Before you start your search, clearly understand your business needs and how that impacts software choices.