Creating Managed Applications

Windows Automotive 5.0/5.5

Use .NET Micro Framework to create managed applications with a basic infrastructure that developers of constrained embedded systems need for fast, seamless development. The customized CLR and the class libraries are carefully crafted for use on small embedded devices. This programming model contains the same key components as the .NET Framework and the .NET Compact Framework. Specifically, it employs a common language runtime (CLR) and a set of class libraries.

For more specific information on the .NET Micro Framework hardware and software architecture, see Understanding .NET Micro Framework Architecture.


The CLR is an agent that manages code at execution time, providing core services such as memory management, thread management, and remoting, while also enforcing strict type safety and other forms of code accuracy that promote application security and robustness. In fact, the concept of code management is a fundamental principle of the CLR. Code that targets the CLR is referred to as managed code, whereas code that does not target the CLR is known as unmanaged code.

In addition, the managed environment of the runtime eliminates many common software issues. For example, the runtime automatically handles object layout and manages references to objects, releasing them when they are no longer being used. This automatic memory management resolves the two most common application errors — memory leaks and invalid memory references.

The Class Library

The class library included with the .NET Micro Framework is an object-oriented collection of reusable types you can use to develop embedded applications. Its classes are tightly integrated with the CLR and provide you with types you can employ to build functionality into your own managed code. For example, the .NET Micro Framework collection classes implement a set of interfaces you can use to develop your own collection classes. Your collection classes will blend seamlessly with the classes in the .NET Framework.

Also, the class library contains specialized classes that are designed to give you access to the hardware features of your product's embedded system. For instance, your program can communicate across standard hardware interfaces, such as GPIO, I2C, and SPI. The powerful combination of standard .NET classes and hardware-specific objects can greatly reduce the amount of time required to develop your embedded system.

The .NET Micro Framework class library includes classes, interfaces, and value types that expedite and optimize the development process and provide access to system functionality. These types are the foundation on which you build your embedded applications and components. They provide a rich set of interfaces, as well as abstract and concrete (nonabstract) classes. You can either use the concrete classes as they are or, in many cases, derive your own classes from them. To use an interface's functionality, you can either create a class that implements the interface or derive a class from one of the .NET Micro Framework classes that implements the interface.

Naming Conventions

The .NET Micro Framework types use a dot syntax naming scheme that connotes a hierarchy. This technique groups related types into namespaces, making them easy to search and reference. The first part of the full name — up to the rightmost dot — is the namespace name. The last part of the name is the type name. For example, System.Collections.ArrayList represents the ArrayList type, which belongs to the System.Collections namespace. The types in System.Collections can be used to manipulate collections of objects.

This naming scheme makes it easy for library developers extending the .NET Micro Framework to create hierarchical groups of types and name them in a consistent, informative manner. It is expected that library developers will use the following syntax when creating names for their namespaces:


Microsoft.Word is an example of a namespace that conforms to this naming convention.

The use of naming patterns to group related types into namespaces is a very handy way to build and document class libraries. However, this naming scheme has no effect on visibility, member access, inheritance, security, or binding. A namespace can be partitioned across multiple assemblies; and conversely, a single assembly can contain types from multiple namespaces. The assembly provides the formal structure for versioning, deployment, security, loading, and visibility in the CLR.

Essential Namespaces

The System namespace is the root namespace for many of the fundamental types in the .NET Micro Framework. This namespace includes classes that represent the base data types used by all applications: Object (the root of the inheritance hierarchy), Byte, Char, Array, Int32, and String, among others. Many of these types correspond to the primitive data types provided by C#, which is currently the only programming language supported by the .NET Micro Framework CLR.

Other important namespaces in .NET Micro Framework programming are Microsoft.SPOT and Microsoft.SPOT.Hardware. These namespaces provide access to much of the hardware-level functionality that the .NET Micro Framework supports.

Community Additions