The Microsoft .NET, more commonly known as simply the .NET Framework, is a software development platform created by Microsoft. The .NET Framework is now in version 4.8, which was released in October of 2019. It is a Microsoft technology that allows cross-language development and provides a large standard library. Other competing approaches are cross-platform languages, i.e. Perl, using a cross-platform runtime like the Java Virtual Machine, or compile standard ANSI C to each platform.

Microsoft .NET is free, cross-platform and open source platform for building cross platform applications. Developers can write .NET applications in any supported programming languages such as C#, F# or Visual Basic. You can use code editors, and libraries to build for web, mobile, desktop, games, and IoT.

What is Microsoft .NET Framework?

The Microsoft .NET Framework was designed with several intentions :

  1. Common Runtime Engine – Programming languages on the .NET Framework compile into an intermediate language known as the Common Intermediate Language, or CIL; Microsoft’s implementation of CIL is known as Microsoft Intermediate Language, or MSIL. Unlike the Java platform, however, this intermediate language is not interpreted, but rather compiled in a manner known as just-in-time compilation (JIT) into native code. The combination of these concepts is called the Common Language Infrastructure (CLI), a specification; Microsoft’s implementation
    of the CLI is known as the Common Language Runtime (CLR).
  2. Interoperability – Because so many COM libraries have already been created, the .NET Framework provides methods for allowing interoperability between new code and existing libraries.
  3. Language Independence – The .NET Framework introduces a Common Type System, or CTS. The CTS specification defines all possible datatypes and programming constructs supported by the CLR and how they may or may not interact with each other. Because of this feature, the .NET Framework supports development in multiple programming languages. This is discussed in more detail in the .NET languages section below.
  4. Base Class Library – The Base Class Library (BCL), sometimes referred to as the Framework Class Library (FCL), is a library of types available to all languages using the .NET Framework. The BCL provides classes which encapsulate a number of common functions such as file reading and writing, graphic rendering, database interaction, XML document manipulation, and so forth.
  5. Simplified Deployment – Installation and deployment of Windows applications has been the bane of many developers’ existence. Registry settings, file distribution and DLL hell have been nearly completely eliminated by new deployment mechanisms in the .NET Framework.
  6. Security – .NET allows for code to be run with different trust levels without the use of a separate sandbox.

Microsoft .NET Platform comprises of four core components such as

  1. .NET Building Block Services such as file storage, calendar called Passport. NET
  2. .NET Device Software which will run on latest Internet Devices like Mobile Phones.
  3. .NET user experience such as integrating this technology to user created documents (integrates with XML). For example if you code XML via a .NET Language like C#, it will automatically
    create XML document
  4. .NET infrastructure which includes
    1. .NET Framework (Common Language Runtime & .NET Framework Class Libraries)
    2. Microsoft Visual Studio.NET such as Visual Basic.NET ,Visual C++.NET etc
    3. .NET Enterprise Servers and Microsoft Windows. NET

We can build robust, scalable, distributed applications with the help of .NET and the part that helps us to develop these applications is called the .NET Framework. The .NET Framework contains Common Language Runtime (CLR) and the .NET Framework class libraries also called as Base Class Libraries.

All the .NET languages (like C-sharp, VisualBasic.NET, Visual C++. NET etc) have the .NET Framework class libraries built into them. The .NET class Libraries also supports File I/O, database operations, XML (Extensible Markup Language) and SOAP (Simple Object Access Protocol). For example you can develop XML Pages by using C-sharp language.

When someone talks about .NET development, then you should understand that they are talking about .NET Framework. It includes a Runtime environment and a set of Class Libraries which is being used by a new language called C-sharp abbreviated as C# (more or less similar to C/C++/Java family of languages) and all other .NET Languages. Simply speaking C-sharp is a new language for developing custom solutions for Microsoft’s .NET Platform.

.NET Implementations

At its heart, .NET is about a runtime that supports a certain set of features. If you want to know what .NET is, then, here is a list of implementations that provide something tangible for you to work with. Microsoft has created three public implementations of .NET, and there are at least two other efforts underway to create .NET runtimes.

  • .NET Framework ? Microsoft’s runtime for desktop and server versions of Microsoft Windows. It is included with two shipping Microsoft operating systems: Windows XP Tablet Edition, and Windows 2003 Server; and is offered as a downloadable installation file, dotnetfx.exe for other versions of Windows (Windows 98 and later).) through a downloadable installation file, dotnetfx.exe.
  • Shared Source CLI ? Microsoft has released the source code to Rotor, an implementation of the Common Language Infrastructure (CLI), in support of its submission to ECMA of this .NET technology as an ECMA approved standard. This can be downloaded from the Microsoft web site, and used as a resource to learn about the architecture and operation of the .NET runtime
  • .NET Compact Framework ? Microsoft’s runtime for Windows CE-powered platforms, and of course the subject of this book.
  • DotGNU ? The GNU project for building an open source implementation of the .NET Framework.
  • Mono Project ? Another open source project to create an implementation of the .NET Framework from a company called Ximian

Common Language Runtime

Common Language Runtime also called CLR Provides a universal execution engine for developers code. It generates SOAP when it makes remote procedure calls. CLR is independent and is provided as part of the .NET Framework. The main features of CLR are as follows

  • Managed Code
  • Automatic application installation
  • Memory Management
  • Automatic Garbage Collection
  • Very high level of Security while executing

The Common Language Runtime (CLR) is the engine behind managed applications created with Visual C++ .NET. In the “An Overview of .NET” section of the chapter, we discussed how CLR uses a stack-based approach to managing applications. In other words, the IL file contains directives for loading data onto the stack, performing an operation on the data, and then storing the data into memory. Because IL uses generalized instructions, the same file could potentially work on any platform. However, this is a theoretical advantage now because the only place you’ll find .NET is as part of Windows (and not even all Windows, such as Windows 9x, support it).

The central part of CLR is MSCOREE.DLL. Every managed application contains a reference to this DLL. MSCOREE.DLL performs a lot of work on behalf of the application by managing memory and enabling the developer to discover every aspect of every type (not just those that are exported from objects, as in COM). CLR calls all standalone components or functional applications assemblies, and each assembly contains one or more types. COM uses a separate 128-bit key to identify each type. CLR uses a 128-bit key for the assembly, then refers to each type within the assembly using a strong name. The effect of both techniques is the same, just different; every type has a unique identifier, but CLR uses a different method to provide this identifier.

One of the advantages of using CLR is that it doesn’t discriminate between languages. For example, under the old COM system, Visual Basic developers used one method (IDispatch) to define types and Visual C++ developers used a different technique (IDL). These language differences caused a number of problems for COM developers when working in mixed language environments. CLR uses a single technique to describe types. The binary format enables all languages to gain access to type information using the same methodologies. Here’s the same interface described using C#:

Anyone who’s worked with components in an unmanaged environment knows about IUnknown and the VARIANT type. The first is the root type for all objects, while the second is the root type for all values. Both of these root types no longer exist under .NET. CLR uses a single root type, System.Object, for all types. Checking against a system or a user-defined type enables you to detect the type of an incoming value, which is more convenient and errorproof than previous techniques.

.NET Framework Class Libraries

These class libraries works with any language under the common language runtime environment. It includes Visual Studio.NET, C-Sharp. Therefore if you are familiar with one .NET language then you can easily migrate to other .NET Languages. The figure given below shows the .NET Framework hierarchy

NAMESPACES ==>>CLASSES ==>> METHODS

  • All namespaces should have to be called in your Program by applying the keyword using. For example if your programs needs to call System namespace, then it should be applied in the program as using System.
  • Classes cannot be called along with the using directive.
  • The using directive applies only to namespaces, just like importing packages in Java. Hence the following code will result in compilation error, using System.Console.

However you can create an alias like the following using mysys = System.Console. Then you have to apply the alias in your program as follows mysys.writeLine(“Hello C#”);

Common Language Specification (CLS)

It is a set of rules that a language compiler must adhere to in order to create .NET Applications that run in the CLR. If you are going to create a compiler for .NET, you have to adhere to the rules enumerated in the common language specification and this enables us to create a club of CLS compliant languages.

  • Each such compiler will have the following features
  • Complete access to .NET Framework hierarchy
  • High level of interoperability with other compliant languages like Visual Basic. NET etc.

For example a Visual Basic class can inherit from a C# Class You should note that the syntaxes and other programming structures differ from each of these languages. The only difference is that a developer well versed with a language such as C-sharp can easily program in Visual Basic.NET or Visual C++.NET without investing a lot or spending too long to learn a new language.

An Overview of the .NET Framework Namespaces

You can look at the .NET Framework in many ways. However, there’s one undeniable use of the .NET Framework that all developers can appreciate: The .NET Framework is a method of organizing code to make it easier to access and use. Given the disorganized state of the Windows API, making the move to .NET makes sense even if your only reason is to gain a little sanity in the development environment.

Note Microsoft promises a lot from the .NET Framework, but doesn’t always deliver precisely what developers want. The .NET Framework is a work in progress. You’ll discover that the .NET Framework doesn’t provide complete coverage at this point, so you’ll need to access the Windows API to perform selected tasks. For example, if you want 3D graphics, you’ll need to access the Windows API or use DirectX-the .NET Framework offers nothing to meet your needs. We’ll discuss some of these problem areas as the book progresses.

As you begin creating your own applications, you’ll develop libraries of routines that you can use in more than one application. C# has no rule stating that you must place these classes within namespaces, but namespaces are a great organizational tool, especially if you plan to share this code with anyone. Using a company namespace helps prevent confusion in shared code. If two companies create a class or method of the same name, using a namespace can provide the distinction needed to avoid problems with application code. Microsoft provides two namespaces with the .NET Framework. The first namespace, Microsoft, contains access to what you might term as Windows-specific functionality. For example, this is the namespace that contains the Registry classes and you’ll use classes in this namespace to manage power. The second namespace is System. The System namespace contains framework-generic classes. For example, this is the namespace that defines the data types used within C#.