The .NET Framework is a software solution used by developers to create applications for the suite of Windows operating environments which include: Windows, Windows Phone, Windows Server, and Microsoft Azure (cloud platform). The .NET Framework includes tens of thousands of classes, interfaces, and types. It consists of two primary components, the common language runtime (CLR) and the framework class library (FCL) which are discussed below. The common type system (CTS) and common language specification (CLS) are also two additional constituents of .NET and are briefly mentioned here.
Common Language Runtime (CLR)
The .NET CLR provides a runtime environment (or engine) for a variety of .NET-aware languages including C#, VB.NET, C++, and many others. It is referred to as "common" since one engine supports a multitude of languages. There are two compilation phases that C# (or any other managed .NET language) goes through. When we compiled our HelloWorld examples on the Getting Started page, we used the C# compiler (csc.exe). That compiler produces a form of "byte code" known as Microsoft intermediate language (MSIL - pronounced "missile"). MSIL is also referred to as common intermediate language (CIL) or intermediate language (IL). The same (or very similar) byte code is produced by the CLR irrespective of the language.
When a .NET program is run, either from the command line or by double-clicking an icon, the CLR converts the byte code into platform-specific machine language which the CPU can then process. The key library associated with the conversion is mscoree.dll (common object runtime execution engine). The execution engine is a just-in-time (JIT) compiler that translates the MSIL into native (machine) code which is then executed by the CPU. The figure below diagrams this process. Which, by the way, is similar to the process employed by the JVM (Java Virtual Machine) for the Java language.
Framework Class Library (FCL)
The .NET FCL consists of more than 100 namespaces which collectively contain thousands of types (i.e. classes, structures, delegates, enumerations, and interfaces). The FCL provides developers with reusable core system and application services. Instead or reinventing the wheel, a developer can leverage the existing classes within the FCL. Examples of the functionality offered by the FCL include: multi-threading, file I/O, object serialization, security, and database operations. We will apply the FCL to solutions in subsequent chapters.
.NET CTS and CLS
In addition to the CLR and FCL, .NET also includes a common type system (CTS) and common language specification (CLS). The CTS ensures types translate seamlessly across .NET-aware languages. In .NET, a type is defined as any one of the following: classes, structures, delegates, enumerations, and interfaces. The CLS delineates the set of features .NET-aware languages and .NET compilers must support. The CLS specifies usage conventions required for language and compiler efficient and effective operation.
Another aspect of .NET that is worthy of mention is .NET Native. Native is a .NET compiler that translates C# into native machine code thus skipping the MSIL and JIT steps described above. Early tests suggest that some Windows Store apps load up to 60% faster and consume 15-20% less memory when the source code was compiled with the .NET Native compiler. Note that Native is initially only available for Windows Store apps but other platforms will likely be targeted in the future.
.NET and WinRT
Windows Runtime (WinRT) is a new framework first introduced for developing Windows 8 (Metro) applications. The WinRT applications are intended to run on devices with "touch" capabilities such as Windows Phone and the Windows Surface portables. The .NET Framework is still quite relevant since it is, and will be for the foreseeable future, the framework utilized with C# for Windows desktop development.
Now that you have more understanding the .NET workflow, it is probably a good time to go back to the Getting Started chapter and walk through the examples again. Keep in mind that csc.exe produces MSIL and when the HelloWorld programs are run, the execution engine (in mscoree.dll) translates the MSIL into native machine code that the CPU runs. In the next chapter, we consider an overview of C#.