Microsoft's .NET Framework is a software framework that contains huge library of coded solutions to general programming problems, and a Virtual Machine (CLR) that manages the execution of programs. The CLR (Common Language Runtime) is the most vital component of the .NET Framework. It provides the execution environment for the programs, and manages features such as garbage collection, memory management and so on.
The .NET Compact Framework (.NET CF) is a subset of the .NET Framework. .NET CF is a lightweight; hardware-independent environment that supports the development of managed applications for Windows CE-based mobile and embedded devices such as mobile phones and PDAs. The .NET CF CLR has all the important features of its 'full-size counterpart, including memory management, type safety, security and execution environment.
Basic Common Features of .NET CF CLR and 'full-size' .NET Framework CLR
The following features are common to all .NET CLRs.
1. Reflection – This feature enables the developer to get information about the object at runtime. That information may include the data of the class or names of the methods or properties.
2. Serialization – This is the process of converting an object into a compact representation, so that transmission and storage of the object becomes easy on different platforms.
3. Memory management – This includes memory allocation, memory defragmentation and garbage collection. Crucially, this prevents memory leaks.
4. Exception handling – An error that arises at runtime is known as an 'exception'. The execution engine of the framework manages dispatching and cleanup associated with exceptions, and protects the integrity of the system.
5. Security – The .NET Framework provides the inherent security advantages of managed code using its Code Access Security (CAS) feature. All the assemblies that are loaded onto the framework must be signed with a single key. The .NET framework also contains several cryptographic libraries that a developer can use to design secure systems.
Distinct Features Available In .NET Compact Framework CLR
The following features are only available in .NET Compact Framework CLR
1. .NET CF internally represents strings in UTF-8 format, and exposes them as Unicode.
2. The special garbage collector of .NET CF provides automatic memory management and continuous storage management.
3. Instead of using metadata, the .NET CF CLR uses self-describing data. This enhances the performance of the garbage collector.
4. .The NET CF includes support for patching, including assembly differencing, method and resource substitution.
5. .The NET CF CLR does not uses Virtual tables for the resolution of functions. This feature helps to save memory.
6. .The NET CF CLR prioritises and stores extended weak references of the objects in flash memory. This helps it to manage memory more effectively.
7. The .NET CF CLR imposes a limit on call durations, so if a method call takes more than the specified time, the CLR aborts it. This feature enables to prevent system hangs.
8. The .NET CF CLR uses a global shared string table for types, methods and fields. This feature reduces the usage of RAM/ROM.
9. The .NET CF CLR includes a custom serialisation engine that produces more a compact representation of the object than the 'full-size' .NET CLR.
10. The runtime emulation of Value types allows the optimisation of garbage collection and lowers RAM usage.
The .NET Compact Framework contains a much smaller set of libraries than the 'full-size' .NET framework, as .NET Compact Framework is designed for computing devices with fewer resourced. However, both frameworks provide a consistent programming model. Developers who are using .NET Framework for software development will find it easier to adopt .NET Compact Framework.