Welcome!

.NET Authors: Jim Kaskade, Adine Deford, TJ Randall, Sandi Mappic, Ivan Antsipau

Related Topics: .NET

.NET: Article

Questions and Answers on the .NET Compact Framework

Questions and Answers on the .NET Compact Framework

As many developers are already aware, the impending release of Visual Studio .NET 2003 will serve to bring the benefits of XML Web Services and the Microsoft Windows .NET Framework to smart devices via the inclusion of the .NET Compact Framework and Smart Device Projects. However, for those not already initiated, the following excerpts from Building Solutions with the .NET Compact Framework will explore the five basic questions that every developer asks when first thinking about the Compact Framework.

What Are the Goals of the Compact Framework?
Simply put, the goals of the Compact Framework (and Smart Device Projects) are fourfold:

  • To provide a portable (and small) subset of the Windows .NET Framework targeting multiple platforms. This includes the creation of a runtime engine, class libraries, and compilers for VB and C# that together are referred to as the .NET Compact Framework. This framework is not a simple port of the desktop version, but a complete rewrite designed to execute managed code on multiple CPU architectures and operating systems through an abstraction layer known as the Platform Adaption Layer (PAL). It is important to note that the Compact Framework was also designed to be a subset of the desktop version of the Framework. As a result, roughly 25% of the desktop types are represented in the Compact Framework.
  • Leverage VS .NET. Since VS .NET already provides a high productivity development environment, it is only natural that this environment should be utilized in developing mobile applications as well. To that end, the Smart Device Projects for VS .NET 2003 provide the project templates, emulator, debugger, and device integration to use the same IDE for desktop as for mobile development.
  • True Emulation. One of the requirements for developing robust (i.e., well-debugged) mobile applications is that they run as expected when installed on the device. To that end VS.NET includes emulators for Pocket PC and Windows CE that run exactly the same execution engine and class libraries as those installed on the device. In addition, the emulator supports localized packages for developing global applications. In this way, developers can be assured that the code they write and test with the emulator will execute correctly when deployed to the device.
  • Enable Web Services on Devices. Since XML Web Services are by definition device independent, they can be used from a variety of devices. By building support for consuming web services directly into the Compact Framework, developers can easily call web services.

    On Which Platforms Does It Run?
    Since 1992 Microsoft has produced a series of platforms (9 if our count is correct) built on the Windows CE operating system. A platform includes a specific set of hardware coupled with a version of Windows CE and associated software that makes it easier for developers and device manufacturers to target their solutions. The Compact Framework supports the Pocket PC 2000, 2002, and embedded Windows CE .NET 4.1 platforms. Although not officially supported, Compact Framework code also runs on Pocket PC Phone Edition devices that are a superset of Pocket PC 2002. Also not supported are smartphones such as the SPV from Orange.

    Because the Compact Framework is a managed environment, each device that executes applications written using the Compact Framework must have the framework installed. As of this writing, there were no devices shipping that included the Compact Framework as a standard component in RAM or in ROM. However, look for future devices running Windows CE .NET to include the runtime.

    What About ASP.NET Mobile Controls (aka the Mobile Internet Toolkit)?
    Many developers new to developing for mobility are at first confused by the differences between the Compact Framework and ASP.NET Mobile Controls. In a nutshell here are the primary differences.

  • The ASP.NET Mobile Controls are a server side technology whereas the Compact Framework is a client side technology. This means that code written using mobile controls must execute on a server, and not directly on the device, by producing markup language that is interpreted by the device using a browser or parser. Code written for the Compact Framework executes directly on the device using just-in-time (JIT) compilation and native execution.
  • The ASP.NET Mobile Controls are based on ASP.NET and use the ASP.NET HTTP runtime to handle and process requests via a set of ASP.NET server controls specially designed for small form factor devices. This means that mobile controls require an ASP.NET web server (IIS 5.0 or 6.0). The device issues requests that are processed on the web server by the controls producing markup language.
  • Both ASP.NET Mobile Controls and the Compact Framework are based on the desktop Framework and VS .NET. In the case of mobile controls, developers use VS .NET to write ASP.NET code using the ASP.NET server controls. The server side code is JIT compiled and executed on the web server by the common language runtime. In the case of the Compact Framework the code is written using SDP and subsequently downloaded to the device for JITting and execution using a compact version of the common language runtime.
  • The ASP.NET Mobile Controls are more flexible in that they can dynamically produce various markup languages depending on the requesting device they dynamically detect, including WML, cHTML, HTML, and XHTML (in Visual Studio .NET 2003 and the Framework v1.1). This means that mobile controls can support a broader range of devices (over 200 at last count) including wireless web phones, Pocket PCs, and virtually any device that supports HTTP and HTML. The ASP.NET Mobile Controls also include the ability to add device specific customizations so that as new devices come online their feature set can be identified.
  • Since code written for the Compact Framework is downloaded to the device, the Compact Framework supports connected, occasionally connected, and disconnected scenarios and supports local data storage using XML or SQL Server 2000 Windows CE Edition. ASP.NET Mobile Controls only support the former since an HTTP connection is required to request an ASP.NET page that uses the mobile controls. Basically, this means that mobile controls are targeted for building web sites for a broad variety of connected devices and at the same time not having to rewrite the vast majority of code to deal with differences between those devices.

    As a result you can (and in our estimation should) consider architecting and building your applications using the Compact Framework and SDP when the following are true.

  • You are developing code that will execute on the device, as opposed to applications developed with the ASP.NET Mobile Controls
  • Your applications must run in disconnected, connected, or occasionally connected modes
  • You are targeting the Pocket PC 2000, 2002 or embedded Windows CE .NET platforms

    What's Missing in the Compact Framework?
    In order to accommodate the restricted resources on smart devices the Compact Framework was designed as a subset of the desktop libraries and in fact includes just over 1,700 types, or roughly 25% of the desktop framework. As a result, developers familiar with the desktop Framework should not expect all the functionality they are accustomed to. The most important omissions are listed here:

  • ASP.NET. Because the Compact Framework is designed to support applications that execute on the device, it does not include any support for building web pages hosted on a web server running on the device.
  • COM Interop. Since the Windows CE operating system and the embedded Visual C++ (eVC) tool support creating COM components and ActiveX controls, it would be nice if the Compact Framework supported the same COM Interop functionality (complete with COM callable wrappers and interop assemblies) as does the desktop Framework. Unfortunately, COM Interop did not make it into the initial release of the Compact Framework. However, it is possible to create a DLL wrapper for a COM component using eVC++ and then call the wrapper using the Platform Invoke (PInvoke) feature of the Compact Framework, which allows native APIs to be called.
  • OleDb Access. The Compact Framework omits the System.Data.OleDb namespace and so does not support the ability to make calls directly to a database using the OleDb .NET Data Provider.
  • Generic Serialization. The desktop Framework supports binary serialization of any object through the use of the Serializable attribute, the ISerializable interface, and the XmlSerializer class in the System.Xml.Serialization namespace. This functionality is not supported in the Compact Framework. However, the Compact Framework does support serializing objects to XML for use in XML Web Services and serializing DataSet objects to XML.
  • Asynchronous Delegates. Delegates in both the desktop Framework and Compact Framework can be thought of as object-oriented function pointers. They are used to encapsulate the signature and address of a method to invoke at runtime. While delegates can be called synchronously, they cannot be invoked asynchronously and passed a callback method in the Compact Framework. However, it should be noted that asynchronous operations are supported for some of the networking functionality found in the System.Net namespace and when calling XML Web Services. In other cases, direct manipulation of threads or the use of a thread pool is required.
  • .NET Remoting. In the desktop Framework, it is possible to create applications that communicate with each other across application domains using classes in the System.Runtime.Remoting namespace. This technique allows for data and objects serialized to SOAP or a binary format to be transmitted using TCP or HTTP. This functionality is not supported (in part because Generic Serialization is not supported) in the Compact Framework where instead XML Web Services and IrDA can be used.
  • Reflection Emit. Although the Compact Framework does support runtime type inspection using the System.Reflection namespace, it does not support the ability to emit dynamically created MSIL into an assembly for execution.
  • Printing. Although the Compact Framework does support graphics and drawing, it does not support printing through the System.Drawing.Printing namespace.
  • XPath/XSLT. Support for XML is included in the Compact Framework and allows developers to read and write XML documents using the XmlDocument, XmlReader, and XmlWriter classes. However, it does not support executing XPath queries or performing XSL transformations.
  • Server-side Programming Models. As you would expect, the Compact Framework also does not support the server-side programming models including System.EnterpriseServices (COM+), System.Management (WMI), and System.Messaging (MSMQ).
  • Multi-module Assemblies. The desktop Framework supports the ability to deploy an assembly as a collection of files. This is useful for creating assemblies authored with multiple languages. This feature is not supported in the Compact Framework where a single file (.exe or .dll) represents the entire assembly.

    However, the Compact Framework does support two additional namespaces to support features particular to smart devices (see Table 1).

    In addition, support for the IrDA protocol has been included in the Compact Framework and exposed in the six classes found in the System.Net.Sockets and the System.Net namespaces.

    What Do Developers Need to Learn to Use the Compact Framework Effectively?
    Although VB 6.0 and embedded VB (eVB) developers will feel fairly comfortable with the VB syntax used in SDP, the object-oriented nature of the Compact Framework means that developers need to have a firm grounding in OO concepts in order to maximize their productivity.

    For example, the class libraries in the Compact Framework make extensive use of both implementation and interface inheritance. Developers familiar with these concepts can not only more easily understand the framework, but can write polymorphic code using the framework that is more maintainable and flexible than the component based development typically done in eVB. In the long run, using OO in their own designs allows developers to write less code and make the code that they do write more reusable. Therefore, to take maximum advantage of OO, however, a development organization should also get up to speed on the use of design patterns.

    Of course, because of its close association with the .NET Framework, existing Framework developers will also have a leg up.

    SIDEBAR

    Title:
    Building Solutions with the .NET Compact Framework

    Authors:
    Jon Box and Dan Fox

    Publisher:
    Addison-Wesley

    ISBN:
    0321197887

    Availability: June 2003

  • More Stories By Jon Box

    Jon Box is an Architect Evangelist in Developer & Platform Evangelism with the Microsoft Corporation. He coauthored Building Solutions with the Microsoft .NET Compact Framework, published by Addison-Wesley, and blogs at http://blogs.msdn.com/jonbox/default.aspx.

    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 SOA Software, an API management leader, will exhibit at SYS-CON's 15th International Cloud Expo®, which will take place on November 4–6, 2014, at the Santa Clara Convention Center in Santa Clara, CA. SOA Software is a leading provider of API Management and SOA Governance products that equip business to deliver APIs and SOA together to drive their company to meet its business strategy quickly and effectively. SOA Software’s technology helps businesses to accelerate their digital channels with APIs, drive partner adoption, monetize their assets, and achieve a...
    SYS-CON Events announced today that Aria Systems, the recurring revenue expert, has been named "Bronze Sponsor" of SYS-CON's 15th International Cloud Expo®, which will take place on November 4-6, 2014, at the Santa Clara Convention Center in Santa Clara, CA. Aria Systems helps leading businesses connect their customers with the products and services they love. Industry leaders like Pitney Bowes, Experian, AAA NCNU, VMware, HootSuite and many others choose Aria to power their recurring revenue business and deliver exceptional experiences to their customers.
    SYS-CON Events announced today that AgilePoint, the leading provider of Microsoft-centric Business Process Management software, will exhibit at SYS-CON's 2nd International @ThingsExpo which will take place on November 4–6, 2014, at the Santa Clara Convention Center in Santa Clara, CA. AgilePoint is the leading provider of Microsoft-based Business Process Management (BPM) software products, has 1,300+ on-premise and cloud deployments in 25+ countries and provides the same advanced BPM feature set as J2EE vendors like IBM and Appian for the Microsoft .NET native environment. AgilePoint customer...
    The Internet of Things (IoT) promises to evolve the way the world does business; however, understanding how to apply it to your company can be a mystery. Most people struggle with understanding the potential business uses or tend to get caught up in the technology, resulting in solutions that fail to meet even minimum business goals. In his session at Internet of @ThingsExpo, Jesse Shiah, CEO / President / Co-Founder of AgilePoint Inc., will show what is needed to leverage the IoT to transform your business. He will discuss opportunities and challenges ahead for the IoT from a market and tec...
    SYS-CON Events announced today that Utimaco will exhibit at SYS-CON's 15th International Cloud Expo®, which will take place on November 4–6, 2014, at the Santa Clara Convention Center in Santa Clara, CA. Utimaco is a leading manufacturer of hardware based security solutions that provide the root of trust to keep cryptographic keys safe, secure critical digital infrastructures and protect high value data assets. Only Utimaco delivers a general-purpose hardware security module (HSM) as a customizable platform to easily integrate into existing software solutions, embed business logic and build s...
    One of the biggest challenges when developing connected devices is identifying user value and delivering it through successful user experiences. In his session at Internet of @ThingsExpo, Mike Kuniavsky, Principal Scientist, Innovation Services at PARC, will describe an IoT-specific approach to user experience design that combines approaches from interaction design, industrial design and service design to create experiences that go beyond simple connected gadgets to create lasting, multi-device experiences grounded in people’s real needs and desires.
    SYS-CON Events announced today that TeleStax, the main sponsor of Mobicents, will exhibit at Internet of @ThingsExpo, which will take place on November 4–6, 2014, at the Santa Clara Convention Center in Santa Clara, CA. TeleStax provides Open Source Communications software and services that facilitate the shift from legacy SS7 based IN networks to IP based LTE and IMS networks hosted on private (on-premise), hybrid or public clouds. TeleStax products include Restcomm, JSLEE, SMSC Gateway, USSD Gateway, SS7 Resource Adaptors, SIP Servlets, Rich Multimedia Services, Presence Services/RCS, Diame...
    Samsung VP Jacopo Lenzi, who headed the company's recent SmartThings acquisition under the auspices of Samsung's Open Innovaction Center (OIC), answered a few questions we had about the deal. This interview was in conjunction with our interview with SmartThings CEO Alex Hawkinson. IoT Journal: SmartThings was developed in an open, standards-agnostic platform, and will now be part of Samsung's Open Innovation Center. Can you elaborate on your commitment to keep the platform open? Jacopo Lenzi: Samsung recognizes that true, accelerated innovation cannot be driven from one source, but requires a...
    The Internet of Things will greatly expand the opportunities for data collection and new business models driven off of that data. In her session at Internet of @ThingsExpo, Esmeralda Swartz, CMO of MetraTech, will discuss how for this to be effective you not only need to have infrastructure and operational models capable of utilizing this new phenomenon, but increasingly service providers will need to convince a skeptical public to participate. Get ready to show them the money! Speaker Bio: Esmeralda Swartz, CMO of MetraTech, has spent 16 years as a marketing, product management, and busin...
    Things are being built upon cloud foundations to transform organizations. This CEO Power Panel at 15th Cloud Expo, moderated by Roger Strukhoff, Cloud Expo and @ThingsExpo conference chair, will address the big issues involving these technologies and, more important, the results they will achieve. How important are public, private, and hybrid cloud to the enterprise? How does one define Big Data? And how is the IoT tying all this together?
    We certainly live in interesting technological times. And no more interesting than the current competing IoT standards for connectivity. Various standards bodies, approaches, and ecosystems are vying for mindshare and positioning for a competitive edge. It is clear that when the dust settles, we will have new protocols, evolved protocols, that will change the way we interact with devices and infrastructure. We will also have evolved web protocols, like HTTP/2, that will be changing the very core of our infrastructures. At the same time, we have old approaches made new again like micro-services...
    SYS-CON Events announces a new pavilion on the Cloud Expo floor where WebRTC converges with the Internet of Things. Pavilion will showcase WebRTC and the Internet of Things. 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 devices--computers, smartphones, tablets, and sensors – connected to the Internet by 2020. This number will continue to grow at a rapid pace for the next several decades.
    The only place to be June 9-11 is Cloud Expo & @ThingsExpo 2015 East at the Javits Center in New York City. Join us there as delegates from all over the world come to listen to and engage with speakers & sponsors from the leading Cloud Computing, IoT & Big Data companies. Cloud Expo & @ThingsExpo are the leading events covering the booming market of Cloud Computing, IoT & Big Data for the enterprise. Speakers from all over the world will be hand-picked for their ability to explore the economic strategies that utility/cloud computing provides. Whether public, private, or in a hybrid form, clo...
    SYS-CON Events announced today that Gridstore™, the leader in software-defined storage (SDS) purpose-built for Windows Servers and Hyper-V, will exhibit at SYS-CON's 15th International Cloud Expo®, which will take place on November 4–6, 2014, at the Santa Clara Convention Center in Santa Clara, CA. Gridstore™ is the leader in software-defined storage purpose built for virtualization that is designed to accelerate applications in virtualized environments. Using its patented Server-Side Virtual Controller™ Technology (SVCT) to eliminate the I/O blender effect and accelerate applications Gridsto...
    SYS-CON Events announced today that Red Hat, the world's leading provider of open source solutions, will exhibit at Internet of @ThingsExpo, which will take place on November 4–6, 2014, at the Santa Clara Convention Center in Santa Clara, CA. Red Hat is the world's leading provider of open source software solutions, using a community-powered approach to reliable and high-performing cloud, Linux, middleware, storage and virtualization technologies. Red Hat also offers award-winning support, training, and consulting services. As the connective hub in a global network of enterprises, partners, a...
    As the Internet of Things unfolds, mobile and wearable devices are blurring the line between physical and digital, integrating ever more closely with our interests, our routines, our daily lives. Contextual computing and smart, sensor-equipped spaces bring the potential to walk through a world that recognizes us and responds accordingly. We become continuous transmitters and receivers of data. In his session at Internet of @ThingsExpo, Andrew Bolwell, Director of Innovation for HP’s Printing and Personal Systems Group, will discuss how key attributes of mobile technology – touch input, senso...
    The Internet of Things (IoT) is making everything it touches smarter – smart devices, smart cars and smart cities. And lucky us, we’re just beginning to reap the benefits as we work toward a networked society. However, this technology-driven innovation is impacting more than just individuals. The IoT has an environmental impact as well, which brings us to the theme of this month’s #IoTuesday Twitter chat. The ability to remove inefficiencies through connected objects is driving change throughout every sector, including waste management. BigBelly Solar, located just outside of Boston, is trans...
    Connected devices and the Internet of Things are getting significant momentum in 2014. In his session at Internet of @ThingsExpo, Jim Hunter, Chief Scientist & Technology Evangelist at Greenwave Systems, will examine three key elements that together will drive mass adoption of the IoT before the end of 2015. The first element is the recent advent of robust open source protocols (like AllJoyn and WebRTC) that facilitate M2M communication. The second is broad availability of flexible, cost-effective storage designed to handle the massive surge in back-end data in a world where timely analytics...
    Internet of @ThingsExpo Silicon Valley announced on Thursday its first 12 all-star speakers and sessions for its upcoming event, which will take place November 4-6, 2014, at the Santa Clara Convention Center in California. @ThingsExpo, the first and largest IoT event in the world, debuted at the Javits Center in New York City in June 10-12, 2014 with over 6,000 delegates attending the conference. Among the first 12 announced world class speakers, IBM will present two highly popular IoT sessions, which will take place November 4-6, 2014 at the Santa Clara Convention Center in Santa Clara, Calif...
    From a software development perspective IoT is about programming "things," about connecting them with each other or integrating them with existing applications. In his session at @ThingsExpo, Yakov Fain, co-founder of Farata Systems and SuranceBay, will show you how small IoT-enabled devices from multiple manufacturers can be integrated into the workflow of an enterprise application. This is a practical demo of building a framework and components in HTML/Java/Mobile technologies to serve as a platform that can integrate new devices as they become available on the market.