The basic concepts of .NET Framework technology

The basic concepts of .NET Framework technology


 


1. What is a .NET Framework environment?

.NET Framework serves as a medium to support the development and execution of distributed applications, which are based on the components (controls).

Applications (programs) can be developed in different programming languages, that support this technology.

.NET Framework provides:

  • sharing using of different programming languages;
  • safety and tolerability of programs;
  • common programming model based on the Windows platform.

2. What are the main constituents of the .NET Framework?

From a programming standpoint, .NET Framework consists of two main components:

  • Common Language Runtime (CLR);
  • the base classes library.

CLR solves the tasks of automatic detection of .NET types, loading these types and controlling of them. The CLR environment realizes the memory controlling, application maintenance

The CLR environment realizes the control by memory, application maintenance, processing of threads and implements many checks related with safety.

The base classes library includes the definition of different primitives, that can be: threads, graphic API-interfaces, databases, input/output and so on.


3. What is the principle of the CLR (Common Language Runtime)?

Common Language Runtime controls the executing the .NET code.

After compilation the program in C# (or any other language) is created the file, that contains a special kind of pseudocode or byte-code (but not the executive file, as it was before). This pseudocode is called as “Microsoft Intermediate Language” (MSIL) of Common Intermediate Language (CIL). This pseudocode is the intermediate language of Microsoft.

The main purpose of the CLR – to transform the intermediate MSIL code in the executable code at runtime.

Any program, that is compiled into pseudocode MSIL, can be run in any environment, that contains the CLR realization. This provides the programs portability in the .NET Framework environment.

Figure 1. The process of converting the source code in MSIL language code (CIL of IL) and creating the file of assembly (*.dll or *.exe)

After this, the pseudocode transforms into executable code. This carries out the JIT-compiler. JIT (Just-in-time) compilation – is the compilation “on the fly”.

The CLR executive environment is responsible for determining the assembly placement.

The requested type that is placed in the assembly (for example, an ArrayList class or other type) is determined in a binary file (*.dll or *.exe) with the help of reading the metadata of the file.

After that, it places type in the memory, that was read from assembly.

Then, CLR transforms the CIL-code into the corresponding instructions, that adapt to the specific platform (depending on the PC, operation system, ect.). Also, at this stage the necessary checks on security occur.

The final, the requested code is executed.


4. What is the MSIL (Microsoft Intermediate Language) or CIL (Common Intermediat Language)?

At first, the intermediate language of pseudocode was called Microsoft Intermediate Language (MSIL). Later (in recent versions of .NET) this name was changed to Common Intermediate Language (CILCommon Intermediate Language). Abbreviations MSIL, CIL and IL (Intermediate Language) mean the same thing.

The intermediate language CIL (or MSIL) generated after compiling the program in some programming language that supports the .NET Framework platform.

MSIL is a pseudocode.

MSIL determines the set of instructions, which:

  • they can be transfered on different platforms;
  • aren’t depend on specific processor.

In fact, MSIL is a portable assembly language.


5. What is the assembly from the point of view of .NET technology?

Assemblies are the files with the extension *.dll or *.exe, which contain the instructions, that are independent of the .NET language, and metadata of types. These instructions are realized on the intermediate language (IL).

Assembly is created by using the .NET compiler. Assembly is a big binary object.

The assembly is designed to save the namespaces. Namespaces contain types. The types may be classes, delegates, interfaces, enumerations, structures.

The assembly may comprise any number of namespaces. Any namespace may contain any number of types (classes, interfaces, structures, enumerations, delegates).


6. What is placed in the assembly?

The assembly contains CIL-code (MSIL-code or IL-code) and metadata. CIL-code is compiled for a specific platform only when it is accessed from the .NET.

Metadata describe in detail the features of each type, which is inside of the .NET binary unit.

For example, when you create a “Windows Forms Application” type applications in C#, the “Assembly.info” file is created. This file is located in a “Properties” subfolder relative to the main program folder. This file specifies general information about the assembly.


7. What is the manifest?

Manifesto – a description of the assembly itself with the help of metadata.

The information is placed in the manifest:

  • about the current version of the assembly;
  • about a culture (strings localization, graphic resources);
  • a list of references to all external assemblies that are necessary for the proper functioning.

8. The scheme of interaction between the source code, .NET compiler and .NET implementation mechanism.

The programmer creates the source code in a language that supports the .NET technology (language C#, C++/CLI, Visual Basic .NET, etc.). The application is created in a programming environment such as Microsoft Visual Studio. The compiler generates an assembly – a file that contains CIL-instructions, metadata, and manifest.

After starting on the execution of the application at a computer (a platform), the mechanism of implementing .NET is started in the work. Previously, you need to install the .NET Framework on your computer (at least).

If you are using the base class libraries (e.g. mscorlib.dll assembly) in the source code, then they are loaded with the help of class loader.

JIT-compiler provides a compilation of the assembly based on the hardware and software features of computer, on which the application is run.

After that, the application runs.

Figure 2. Relationship between the source code, compiler and a mechanism .NET


9. What are the assemblies types?

There are two types of assemblies:

  • single-file assemblies;
  • multifile assemblies.

The assembly, that consists of a single module (*.dll or *.exe) is called a single-file assembly. In the single-file assembly all necessary CIL-instructions, metadata and manifests are placed in a single package.

The assembly, which consists of many files of binary .NET code, is called multifile. Each of these files is called a module.

In the multifile assembly one of the modules is the main (primary).


10. In what file is located the main assembly of MS Visual Studio library?

The main assembly is placed in the “mscorlib.dll” file.


11. What is the general system of CTS types?

CTS (Common Type System) – type system, which contains a complete description of all possible datatypes and programming constructs supported by the CLR environment. Also, here is described how these entities can interact with one another.

The types may be: classes, interfaces, structures, enumerations, delegates.


12. What is the purpose of Common Language Specification (CLS)?

As we know, not all programming languages ​​that are compatible with .NET, can maintain the functionality of the CTS type system. For this purpose, is used the Common Language Specification (CLS).

The aim of CLS is a description of that a subset of the general types and programming constructs that are perceived absolutely by all programming languages ​​that support .NET.


13. What programming languages support the .NET technology?

MS Visual Studio supports the following programming languages: C#, Visual Basic .NET, C++/CLI, JScript .NET, F#, J#.

In order to be able to use the .NET technology you need to install on your computer Microsoft .NET Framework Software Development Kit (SDK) or Microsoft Visual Studio any version.


14. What is the namespace?

The namespace is designed to combine the groups of types that are bound together with a semantic point of view. Types are placed in assemblies. The types are classes, delegates, interfaces, structures, enumerations.

Examples of names the namespaces:

System
System.Data
System.IO
System.Collections
System.Threading.Tasks

For example, in the System.Data namespace are placed the main types for work with databases, in the System.Collections namespace are placed the main types for work with collections.


15. How to display the contents of assemblies, namespaces and types of MS Visual Studio?

In Microsoft Visual Studio system have Object Browser utility, which is called with the View menu (Figure 3).

Figure 3. Calling the utility “Object Browser

This opens the Object Browser window in which the assemblies, that are used in a particular technology, will be displayed.

Figure 4 shows a list of assemblies that are displayed in the technology “.NET Framework 4“. The assembly named “mscorlib” is selected.

Figure 4. The “Object Browser” window with a selected assembly “mscorlib.dll

If reveal the content of the assembly “mscorlib” (“+” sign),then it will display a list of all the namespaces of the assembly (Figure 5). As can be seen from the figure, the assembly includes the namespaces Microsoft.Win32, System, System.Collections, System.Collections.Concurrent and many others.

Figure 5. The assembly “mscorlib” and a list of namespaces that are included in it

Similarly, the any of the namespaces is revealed. The namespaces describes the types. The types define methods, properties, constants, etc.

Figure 6 shows BinaryReader class from the System.IO namespace. As you can see, in the class are implemented methods with names BinaryReader(), Close(), Dispose(), FillBuffer(), and others.

Figure 6. Content of class BinaryReader


16. How do I connect the namespace in a program on C#?

To include a namespace in the program need to use the “using” word.

The examples of connecting the namespaces:

using System;
using System.IO; 
using System.Windows.Forms;

After connecting the namespace, it is possible to call the types, which are realized in it.