History of .Net Framework Architecture

  • The Development of .Net Framework Architecture was started in 1998 by Microsoft Inc.
  • Finally, in December, the first commercially stable forms came on the market in Feb 2002.

Introduction of .Net Framework Architecture

  • Microsoft has combined various modern as well as existing technologies of software development in .NET Framework.
  • It is believed that there are about 3-4 million/more Java programmers present today but about 3 million/more Visual C++ developers, 3-8 million/more VB developers, and around 1 million/more C# developers available in the world. Thus, we can say that today, most development and deployment occurs in a Windows environment.

Definition of .Net Framework Architecture

  • The .NET Framework Architecture in VB .Net is a new, complete, software programming environment/platform/technology that allows developers to develop, run, and deploy different types of applications in one environment.

Features of .Net Framework Architecture

.Net Framework Architecture –

  • Built for the web.
  • Sits on top of the OS.
  • Gives unified API and multi-language support.
  • Runs primarily on Microsoft Windows OS but may run on all OS.
  • Has a strong emphasis on Web connectivity, using XML web services to connect and share data between smart client devices, servers, and developers/users along with several latest technologies.
  • These technologies are used by developers to develop highly efficient applications for modern as well as future business needs.

.Net Frame Architecture

.Net Framework Architecture : Coders HelplineThere are following core components of the .NET Framework level wise are: –

  • Multiple Programming Languages:
    • .Net Framework supports multiple Microsoft languages such as VB .Net, C#, Visual C++, F#, JavaScript, etc., and other languages such as COBOL, Eiffel, Fortran, Mercury, Pascal, Python, Ruby, SML, Perl, Smalltalk, etc.
  • Common Language Specification(CLS) :
    • The Common Language Specification (CLS) in the .NET Framework is a set of rules and guidelines that ensure interoperability among different .NET programming languages. The CLS defines a subset of common features and language constructs that all .NET languages can use and understand, allowing developers to create libraries and components accessible across various .NET languages.
    • The primary purpose of the CLS is to enable code written in one .NET language (like C#, VB.NET, or F#) to be used seamlessly in another .NET language.
    • The CLS includes a set of common features that all .NET languages are expected to support. This includes basic data types (like integers, strings, and booleans), control structures (like loops and conditionals), and other fundamental programming constructs.
    • Members marked as public or protected are part of the CLS, while private and internal members are not. This means that CLS compliance mainly concerns publicly accessible parts of the code.
    • The Common Language Specification (CLS) is a foundational element of the .NET Framework that promotes language interoperability by defining a set of common rules and guidelines.
    • CLS is an agreement among language and class library designers about the features and usage conventions that can be relied upon.
    • The CLS provides a standardized set of features and practices, reducing the likelihood of encountering language-specific problems and incompatibilities.
  • Framework Class Library(FCL) :
    • The class library and the CLR together constitute the major part of the .NET Framework.
    • The Framework Class Library is a fundamental part of the .NET Framework, offering a vast and rich set of functionalities that simplify the development of various types of applications.
    • The FCL contains thousands of classes that provide a wide range of functionalities, from basic system operations to advanced data structures, cryptography, file I/O, networking, threading, and much more. It includes a large no. of libraries(above 9000 libraries) hence rich in in-built methods which may be used in programming environments. The extensive library of pre-built classes allows developers to quickly implement complex functionality without writing everything from scratch.
    • FCL is a comprehensive collection of reusable classes, interfaces, and value types that are tightly integrated with the .NET Framework, providing a consistent object-oriented programming environment across various languages.
    • The FCL is one of the core components of the .NET Framework and serves as the building block for developing applications, services, and components in the .NET environment.
    • The Class library contains the Base classes related to networking, security, I/O files, Windows UI, Data and XML Classes, Web Services/UI, etc.
    • The FCL follows the principles of object-oriented programming (OOP), making it easier to create and manage complex applications through inheritance, polymorphism, encapsulation, and other OOP concepts.
    • This .NET library is available to all .Net supporting programming languages.
    • The System namespace is the root namespace in the FCL and includes fundamental classes and base types such as Object, String, Boolean, Array, and many others.
  • Common Language Runtime(CLR) :
    • The CLR is the core part of the .NET platform and is hence called the execution engine.
    • Programs written for the .NET Framework execute in a software environment, known as the Common Language Runtime (CLR), an application virtual machine that provides important services such as security, memory management, and exception handling.
    • CLR provides a common runtime environment for all .NET language’s codes irrespective of their programming language.
    • As we know .NET applications built into Windows form run an executable file by invoking the CLR automatically instead of explicitly invoking the JVM.
    • The CLR provides a “Managed Execution Environment” i.e. It manages the execution of code and provides services that make development easier (like the JVM).
    • CLR provides an environment to execute .NET applications on target machines.
    • CLR also provides various services to execute processes, such as memory management service and security services.
    • CLR also performs various tasks to manage the execution process of .NET applications.
    • MSIL(Microsoft Intermediate Language)/IL/CIL(Common IL) :
      • MSIL is one of the main components of CLR and is a low-level programming language used in the .NET Framework.
      • MSIL is a CPU-independent set of instructions that can be efficiently converted to native machine code by the Just-In-Time (JIT) compiler at runtime.
      • There are separate compilers for the Visual Basic, C#, and Visual C++ programming languages in .NET Framework. Each .NET language compiler produces an intermediate code after compiling the source code. The intermediate code is common for all languages and is understandable only in the .NET environment. This intermediate code is known as MSIL.
      • MSIL is a language that lies between high-level languages (like C#) and machine code (native code). When you compile a .NET application, the high-level source code is not directly converted into machine code but is first compiled into MSIL. This IL code is stored in an assembly, typically a .dll or .exe file.
      • MSIL is platform-independent, meaning the same MSIL code can run on any platform that has a .NET runtime. This makes .NET applications highly portable across different operating systems and hardware architectures.
      • The typical process for executing a .NET application involves two main steps:
        • Source Code to MSIL: The .NET language compiler (e.g., csc for C#) converts the high-level source code into MSIL.
        • MSIL to Native Code: When the application is run, the CLR (Common Language Runtime) uses the JIT (Just-In-Time) compiler to convert MSIL into native machine code specific to the host CPU and operating system.
      • MSIL allows for runtime type safety and security, as well as portable execution platforms.
      • The MSIL architecture results in apps that run in one address space, thus using much less OS overhead.
      • MSIL instructions are stack-based, meaning operations are performed on a stack where values are pushed onto or popped from the stack.
      • MSIL supports object-oriented programming features such as inheritance, polymorphism, and exception handling.
      • MSIL includes instructions for arithmetic operations, memory access, control flow (loops, conditionals), and method calls.
      • MSIL includes built-in support for verification and security. Before execution, the CLR can verify the MSIL code to ensure it meets certain safety and security standards, reducing the risk of executing harmful code.
    • The other responsibilities of CLR are listed as follows:
      • Automatic memory management
      • Garbage Collection
      • Code Access Security
      • Code Verification
      • JIT(Just in Time) compilation of .NET code :
        • JIT is a critical component that enhances the performance of .NET applications by compiling Intermediate Language (IL) code into native machine code at runtime.
        • The JIT compiler is an important element of CLR, which loads MSIL on target machines for execution. The MSIL is stored in .NET assemblies after the developer has compiled the code written in any. NET-compliant programming languages, such as Visual Basic and C#.
        • JIT compiler translates the MSIL code of an assembly and uses the CPU architecture of the target machine to execute a .NET application.
        • JIT compiler also enforces type safety in the runtime environment of the .NET Framework. It checks for the values that are passed to the parameters of any method.
        • JIT supports cross-platform compatibility. By dynamically compiling IL code to native machine code at runtime, the JIT ensures that applications benefit from both the portability of IL and the performance of native code, making it a cornerstone of the .NET runtime environment.
        • During compilation, JIT compilers also produce metadata or glue that binds the code with debuggers, browsers, etc. They may glue definitions of each type in the code, signatures of each type’s members, members that our code references, and other runtime data for the CLR.
        • When code is executed by the CLR, a JIT compilation step occurs as –
          • When a .NET application is developed, the source code (written in languages like C#, VB.NET, F#, etc.) is first compiled by the language’s compiler into an intermediate, platform-independent language called Intermediate Language (IL). This IL code is stored in assemblies, which are typically DLL or EXE files.
          • When a .NET application is executed, the CLR loads the IL code from the assembly into memory. The CLR then relies on the JIT compiler to convert this IL code into native machine code that the CPU can execute.
          • The JIT compiler in the CLR operates on a method-by-method basis. When a method is called for the first time during the execution of an application, the JIT compiler translates the IL code of that method into native machine code.
          • This machine code is then cached, so subsequent calls to the same method can directly use the already compiled machine code, improving performance.
      • Delegates :
        • Delegates in the .NET Framework are powerful and flexible tools for referencing methods in a type-safe manner.
        • In the .NET Framework, delegates are a type-safe, object-oriented way to reference methods used in the .Net Framework. Delegates type-safe means the method of the .Net framework at delegate points must have the same return type and parameter types as the delegate.
        • They are similar to function pointers in C and C++, but delegates are safer and more versatile, as they can reference both static and instance methods and can be used in a variety of programming scenarios such as callback methods, event handling, and LINQ operations. LINQ methods often use delegates to perform operations on collections.
        • A delegate is defined using the delegate keyword, followed by the method signature it will represent.
public delegate int Delegate1(int x, int y)
This defines a delegate named Delegate1 that can reference any method taking two int parameters and returning an int.
        • A delegate holds a reference to a method rather than executing the method itself by assigning a method to a delegate and invoking the method through the delegate.
        • Delegates can reference more than one method at a time. These are known as multicast delegates. When a multicast delegate is invoked, it calls all the methods it references, in the order they were added.
        • Delegates is a new concept that is central to the programming model of the CLR.
        • Delegates are like function pointers of C/C++, but are type-safe, secure, and managed CLR objects.
        • Each delegate is based on a single method signature.
        • CLR is commonly used for callbacks. Delegates are commonly used to implement callback methods, where a method needs to be executed in response to some action, typically in asynchronous programming or event-driven scenarios.
        • Delegates are the foundation of event handling in .NET.

          Delegates are also the basis of event handlers.
  • Common Type System(CTS):
    • CTS is the core/key component of the .Net Framework that defines how data types are declared, used, and managed in the runtime environment.
    • CTS ensures that objects written in different .NET languages can interact with each other seamlessly by providing a common set of data types and rules that all languages in the .NET ecosystem must follow.
    • CTS defines a standard set of data types that all .NET languages must support. This ensures that types defined in one language are understood and can be used in another language of the .Net Framework.
    • CTS enforces type safety, ensuring that the runtime can check for type compatibility, prevent data corruption, and avoid illegal operations on objects.
    • While the CTS defines all possible types that can be used in .NET, the Common Language Specification (CLS) defines a subset of these types and rules that must be adhered to ensure cross-language interoperability.
    • By providing a common type system, CTS enables different .NET languages to work together. For example, a class written in C# can be inherited by a VB.NET class, and vice versa, because both languages follow the same type system.
    • CTS categorizes types into three broad categories: Value Types, Reference Types, and Unified types.
      • Value types
        • Value types contain actual data (cannot be null) that are stored on the stack and always initialized.
        • It directly contains their data.
        • When a value type variable is assigned to another, the data is copied.
        • Value types are typically stored on the stack.
        • When instances of value types go out of scope, they are instantly destroyed and memory is reclaimed.
        • Value types are inherently sealed, meaning they cannot be inherited.
        • They have a fixed size.
        • There are three kinds of value types: Primitives, structures, and enumerations. For example – Primitive Types – int, char, float, bool, etc. ; User-defined Types – structures like struct Point { public int X; public int Y; } ; and Enumerations.
      • Reference Types
        • Reference types are type-safe object pointers and are allocated in the managed heap.
        • When instances of reference types go out of scope, they are garbage collected.
        • Reference types store references (or pointers) to their data.
        • When a reference type variable is assigned to another, both variables refer to the same object in memory.
        • Reference types are typically stored on the heap.
        • They can be null (i.e., not point to any object).
        • Reference types can be inherited.
        • There are four kinds of reference types: Classes, arrays, delegates, and interfaces. For example – Classes – class MyClass { public int MyProperty; }; Interfaces – interface IMyInterface { void MyMethod(); } ; Arrays – int[] array = new int[5]; Delegates: delegate void MyDelegate(int param);
      • Unified Types
        • In CTS, everything is ultimately derived from the System. Object class, which means both value types and reference types share a common base. Hence, Everything in the .Net Framework is considered an object. This is crucial for achieving language interoperability in the .NET Framework.
        • For this, they support Boxing and Unboxing features i.e., the Boxing process is converting an instance of a value type to a reference type. It is usually done implicitly through parameter passing or variable assignments. UnBoxing process is casting a reference type back into a value type variable.
int x = 55; object obj = x; // Boxing: Converting a value type(data) to a reference type(object).
int y = (int)obj; // Unboxing: Converting a reference type(object) back to a value type(data).
      • CTS defines a set of primitive types that are supported across all .NET languages. A comparison between C#’s primitive types and their CTS equivalents is as follows:-
        • int -> System.Int32
        • long -> System.Int64
        • float -> System.Single
        • double -> System.Double
        • bool -> System.Boolean
        • char -> System.Char
        • string -> System.String
        • object -> System.Object
    • CTS supports type conversions, which can be either:
      • Implicit: This conversion is automatically handled by the compiler (e.g., from int to long).
      • Explicit: This conversion requires a cast (e.g., from long to int), and a possible loss of data might occur.
  • The other additional components are –
    • Dynamic Language Runtimes (DLR)
    • .NET Framework Security
    • Side-by-Side Execution
    • Cross-Language Interoperability
    • Application Domains
    • Profiling
    • Runtime Host
    • XML – It is the Metadata or meta-language part of the .Net framework with Self-Describing Components.

Advantages of .Net Framework Architecture

  • .NET Framework provides enormous advantages to software developers in comparison to the advantages provided by other platforms.
  • .Net Framework provides platform/language-independent facilities.
  • They improved reliability and integrated security.
  • They simplified and provided a cost-effective development and deployment.
  • It provides language interoperability across platforms i.e. .NET framework supports multiple programming languages in a manner that allows language interoperability(each language can use the code written in some other languages).
  • It enables a developer to create sharable components to be used in distributed computing architecture.
  • .NET Framework supports the object-oriented programming model for multiple languages, such as Visual Basic, Visual C#, and Visual C++.

Disadvantage of .Net Framework Architecture

  • The .Net framework’s core behavior can’t be modified.
  • Not all libraries are supportive of core functions.

Use/Application of .Net Framework Architecture

  • The .Net Framework helps in making –
    • Console applications
    • Windows Forms applications
    • Windows Presentation Foundation (WPF) applications
    • Web applications (ASP.NET applications)
    • Web services
    • Windows services
    • Service-oriented applications using Windows Communication Foundation (WCF)
    • Workflow-enabled applications using Windows Workflow Foundation (WF)

Loading


2 Comments

Aman Verma · March 28, 2023 at 10:57 PM

This site is very beneficial for me during exams for theoretical knowledge 👍🏻

    Admin · July 3, 2023 at 7:33 AM

    Thanks a lot for your appreciation and will try to make it more and more better. Thank U.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.