ITSE 1330 | C#

ACC

.NET Framework

Foreword

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 D-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 and by the PVM (Python Virtual Machine) for Python.

 

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.

.NET Related Technologies

.NET Native

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 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 (discontinued) and the Windows Surface devices.

Mono

Mono, first released 30Jun2004, is a free and open-source version of the .NET Framework that includes a C# compiler, CLR, and other framework components. It is being led by Xamarin which is a subsidiary of Microsoft. Mono maintains that its goal is to enable cross-platform .NET applications.

Universal Windows Platform (UWP)

UWP was first introduced with Windows 10 on 29Jul2015. The goal of UWP is to enable development for a variety of Microsoft devices such as: Windows 10, Windows 10 Mobile, Xbox One, and HoloLens.

.NET Core

.NET Core is the successor to the .NET Framework. The final version of the .NET Framework (4.8) was released 30Apr2018. Like Mono, .NET Core is free and open-source and enables cross-platform development for Windows, Linux, and macOS. .NET Core launched 12Nov2014 and has had releases through 3.1 on 03Dec2019.

After version 3.1, .NET Core will simply be known as .NET. The first release of the newly branded .NET (without the Core name) will be known as .NET 5 and is anticipated for Nov2020. Subsequent releases are scheduled for every November. That is, .NET 6: Nov2021, .NET 7: Nov2022, etc.

The annual release approach is now common among other software development languages and technologies. For example, ECMA-262 (a.k.a. ECMAScript) is the standard upon which JavaScript is based. Since 2015, it has been on an annual (June) release scehdule.

 

What's Next?

Now that we have an understanding of the .NET workflow and technologies, it is probably a good time to go back to the Let Us Code 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#.