Browse DevX
Sign up for e-mail newsletters from DevX


Mobile CoDe.NET: Exploring the .NET Compact Framework : Page 2

"Windows CE or Mobile Web?" The .NET world can steer you in two very opposite directions: .NET Compact Framework or ASP.NET Mobile Controls.




Building the Right Environment to Support AI, Machine Learning and Deep Learning

What Is the .NET Compact Framework?
Microsoft introduced the .NET Compact Framework to bring the "managed" world of .NET to Windows CE and smart devices. The .NET Compact Framework (.NETcf) is in fact the little cousin of the full-featured .NET Framework which has so radically changed the landscape of Windows and enterprise development over the past 18 months. This analogy actually works pretty well since your little cousin would merely be a smaller "being" very similar to you, not an incomplete version of you with missing parts. The same goes for the .NET Framework and .NETcf: the .NET Compact Framework isn't missing any vital organs found in the full .NET Framework, most of it is there; it is only smaller and less powerful. So why is the .NET Compact Framework smaller? Why do we have to compromise? Well, for starters, the full .NET Framework 1.1 is well over 20 MB in size and most Windows CE devices only have a total of 32 or 64 MB of memory, roughly half of which is used for storage and the other half for program memory allocation. Even if the whole thing was put in ROM (which would require to more than double in size), there still wouldn't be enough RAM or CPU power to run anything. It'd be like running Windows XP and a .NET application on an old Pentium 75 MHz with 32 MB of RAM. The bottom line is very simple: the .NET Framework wasn't designed for such a resource-constrained environment and smart devices needed their own version of .NET.

This is exactly what we got: a scaled-down version of the .NET Framework designed specifically for smart devices and optimized for this limited environment. So what's in there you might wonder? The fact .NET was scaled down implies something was either cut or reduced in functionality, this is true, but instead of focusing on what didn't make the cut, let's start with what we do get in the .NET Compact Framework 1.0:

  • A "compact" CLR (Common Language Runtime) which serves as the execution engine for your managed mobile applications.
  • Support for the full Visual Basic .NET and C# languages.
  • A library of base classes which is in fact a 25-30% subset of the full base class library from the .NET Framework 1.1.
  • A Global Assembly Cache (GAC) that acts as a repository for your shared assemblies and the base class libraries.
  • Error string files (one per language).
  • Globalization data files (one per language/region package).
  • All within a 2.5 MB deployment package.
Throughout this article I'll expand on most of these characteristics, but for now, let's answer the following question: How do you build applications to target the .NET Compact Framework? The answer lies in a new feature of Visual Studio .NET 2003: the Smart Device Extensions.

Smart Device Extensions
Contrary to the previous approach for mobile development in the Microsoft world where the Embedded Visual Tools 3.0 required a separate IDE outside of Visual Studio 6.0, the Smart Device Extensions (SDE) are integrated directly in the Visual Studio .NET 2003 IDE. This feature is available to the Professional Edition and above in Visual Studio .NET 2003 and unless you perform a full install, make sure you select the "Smart Device Programmability" under the Visual Basic .NET and Visual C# .NET languages during setup when choosing which options to install.

With .NET, device programming doesn't bring a new programming model, it reuses an existing one: the .NET model.
With this IDE integration comes a lot of power since you get to use existing Visual Studio components and apply them to mobility projects, such as the Solution Explorer, the Toolbox, the Server Explorer, the Class Viewer, all the documentation features, and many more. For example, the integration with the SDE enables IntelliSense to know which classes exist in the full .NET Framework 1.1 and which can be used legally in SDE projects, thus optimizing productivity regardless of the project type. IntelliSense isn't your only guide in terms of discovering what's in and what's out. The MSDN documentation that ships with Visual Studio .NET 2003 also covers the .NET Compact Framework by tagging supported class members throughout the thousands of online pages with the "Supported by the .NET Compact Framework" label. Hit F1 and search for any class in there and look for this label, indicating whether or not you can use that class or member in your SDE projects.

MSDN also allows you to filter its massive content by selecting the Filtered by option in the Contents pane and then choosing the .NET Compact Framework as the filter parameter. While this will narrow down the library considerably, it won't remove unsupported class members from supported classes. Ultimately, you'll soon realize that trying it first hand is the best way to go since there are a few class members that still won't work even if they are marked "Supported by the .NET Compact Framework."

Thanks for your registration, follow us on our social networks to keep up-to-date