The .Net framework is a software development framework which focuses on development of windows-based applications. It supports the development of various types of applications like console applications, web applications, desktop applications and web services. It includes technologies like WCF, ASP.NET MVC, Windows Forms, ASP.NET Web Forms and ADO.NET. It includes a CLR (Common Language Runtime) which provides features like exception handling, memory management and type safety. CLR functions like a virtual component of the .Net framework which executes different language programs like Visual Basic, C# and F#.
In this dot net tutorial, we will learn about what is dot net technology, its architecture and framework. The article will also cover the features, libraries and application models of .Net. We will also discuss the differences between .Net and ASP.Net framework and .Net Core and Framework to get more clarity. Moving forward, let’s understand what is dot net.
What is .Net?
.Net is a software development framework which is used to create form-based applications. It integrates many different technologies developed by Microsoft and helps applications to develop, evolve, run and deploy windows or web applications. It helps in developing server as well as desktop based applications.
With the help of .Net framework, developers can create big enterprise applications without bothering writing code for pooling, security or transactions. Pooling is the practice of managing and reusing the resources. It helps in reducing resource consumption and hence improving the performance.
Implementation of .Net
There are various types of .Net namely:
1. .NET Framework
The .Net framework is a software development framework which focuses on development of windows-based applications. It supports the development of various types of applications like console applications, web applications, desktop applications and web services. It includes technologies like WCF, ASP.NET MVC, Windows Forms, ASP.NET Web Forms and ADO.NET. The .Net framework supports multiple programming languages. It uses a CIL (Common Intermediate Language) which allows code to be written in various languages to interoperate and share functionality.
2. .NET Core
It is an open source implementation of .Net which supports building applications that can run on Macos, Linux and Windows. It is modular and lightweight which allows developers to include only the necessary components in the applications. This reduces the application size and thereby boosting the performance. It provides a Command Line Interface (CLI) which allows developers to create, build, test and deploy applications. It includes technologies such as Xamarin.Forms, ASP.NET Core and Entity Framework Core.
3. Xamarin
A cross platform app development framework which allows developers to write a single codebase in C# and share the same codebase to different platforms. It allows developers to build mobile applications for Windows and iOS using C# and the .NET platform. Xamarian easily integrates with Visual Studio Code thereby providing a powerful and familiar toolset for development. Xamarin provides Xamarin.Essentials library which provides a collection of cross-platform API’s which handles tasks like file access, connectivity, geolocation etc.
4. ASP.NET
It is a web framework which is developed and designed by Microsoft. It helps in developing dynamic web applications and web services. It allows easy integration with HTML, CSS and Javascript. A popular design pattern in ASP.NET is ASP.NET MVC, where MVC stands for Model View Controller. It divides the application into three components i.e. the Model which is the data and business logic, the user interface which is the View and the Controller which handles user interactions and controls the flow of the application.
5. Blazor
It is an open-source web framework which enables the development of web apps using Razor and C# syntax. Web Assembly in Blazor helps developers to build client-side applications while ASP.NET core helps in building server-side applications. It supports an interactive User Interface and component-based development.
6. Entity Framework
It is an open source ORM (object-relational-mapper) framework for .NET applications. It removes the need for data access code which most of the developers usually have to write. Entity framework provides a high level of abstraction when developers work with data and can create and maintain data oriented applications which have less code as compared to traditional applications. It allows the use of LINQ queries which help in retrieving data from the underlying database.
7. Windows Presentation Foundation
WPF is an open source graphical subsystem within the .NET framework which helps in building visually rich, interactive and appealing user interfaces for windows desktop applications. It uses XAML which stands for eXtensible Application Markup Language which defines and links various interface elements. It also provides a mechanism which helps in designing templates and defining styles which allows consistent behaviour and appearance of various user interface elements.
Why choose .NET?
There are several reasons for a developer to choose .NET technology. A few of them are as follows.
.NET offers a robust and versatile development which helps in building a wide range of applications.
It supports multiple programming languages like C#, F# and Visual Basic.
.Net provides a framework and libraries which simplifies the development tasks.
It also provides a cross platform and an open source development environment.
It allows developers to run on various platforms like Windows, Linux and Macos.
Types of .Net
There are three types of .Net technologies namely:
OLE Technology
OLE refers to Object Linking and Embedding as Microsoft's component document technology that was introduced before the .Net era. It allows applications to create and manipulate compound documents containing objects from different applications. Its primary work is to link different application elements with each other. Linking objects helps establish a connection between them, and embedding facilities facilitate data insertion. OLE also helps transfer application data through clipboard operations and drag and drop. OLE is a legacy technology, and Microsoft encourages developers to shift to new technologies like COM, .Net framework, .Net core, etc.
COM Technology
COM refers to the Common Object Model, which enables different software components to interact and communicate with each other without the need for a platform, i.e., in a platform-independent manner. It is a technology of the Microsoft Windows family which developers mostly use for developing reusable software components and also to build an application by linking different software components together. It also provides a set of procedures, rules, and interfaces for developing and using software components, irrespective of their programming language or operating system. Hence, the objects of COM can be created using a wide range of programming languages. In COM, components communicate with each other using interfaces. Interfaces are a set of methods that are used to interact with a component.
.NET Technology
The .Net technology is developed by Microsoft. It is a software development framework that provides a platform for developing and running various web applications. It is a virtual machine that compiles and executes programs in many different languages like C++.Net, VB.Net, etc. It provides runtime environments, comprehensive libraries, and tools that enhance the development process. Originally, .Net was called NGWS, which stands for Next Generation Web Services and is considered to be the most popular and useful technology available today. The original implementation of .Net, used for Windows-based applications, is known as the .Net framework. .Net core is an open-source implementation of .Net and a cross-platform that supports Linux, macOS, and Windows.
Components of .Net Framework
The two main components of .Net framework are:
Common Language Runtime
CLR or Common Language Runtime is a major component of the .Net framework. It is a virtual machine component which provides a run-time environment that runs the code and makes the development process easier. It manages to compile and execute the .Net programs irrespective of any .Net programming language. The Just-In-Time (JIT) compiler of CLR helps in compiling the intermediate code and generating the corresponding machine code. CLR also does memory management through automatic memory allocation and deallocation. It uses a garbage collector which tracks and manages the memory used by .Net applications. It does exception handling and makes sure that exceptions are caught and handled within the .Net applications. CLR enables interoperability among different programming languages and also does thread management. It enables various security measures that helps to ensure the safety of the applications.
Framework Class Library
FCL is a collection of reusable interfaces, classes and methods which are a part of the .Net framework. It is the same as the header file in Java and C/C++. It includes many pre-built classes which offer a wide range of functionalities like threading, file Input/Output, networking, security and much more. These pre-built classes help in providing a standardized way of performing various common programming tasks. FCL also supports inheritance and interfaces which help in extending and customizing the functionality. It easily gets integrated with other technologies and components within the .Net ecosystem.
.Net Architecture
Following are the components of the .Net Architecture:
1. Common Language Runtime
The CLR is the heart of the .Net Architecture. It functions like a virtual component of the .Net framework which executes different language programs like Visual Basic, C# etc. It provides an execution environment for various .Net applications and provides features like garbage collection, memory management and exception handling. A CLR converts a source code into byte code which is known as MSIL (Microsoft Intermediate Language) or CIL (Common Intermediate Language). This byte code or MSIL code or CIL code is converted into machine code by CLR’s Just-In-Time (JIT) compiler.
2. Common Type System
CTS defines the rules used by .Net languages which ensure code reusability and interoperability. It also specifies the standards which represent the data type and values which can be defined and managed in computer memory at the runtime. It also ensures that programming data defined in various programming languages should interact with each other to share information. It enforces safety by defining rules for data representation, inheritance and method signatures.
3. Base Class Library
BCL provides a comprehensive set of reusable API’s, classes, and types. It contains a huge collection of libraries, features and functions which help in implementing various different programming languages like C#, Visual C++, F# etc. It is further divided into user-defined class library and pre defined class library. BCL simplifies development, promotes code reuse, and enhances productivity by providing pre-built solutions for various common programming tasks.
4. Common Language Specification
CLS defines a set of rules and regulations that ensure interoperability between different programming languages. With the help of CLS, developers can create language-agnostic code that can be easily consumed and used by various other .Net languages.
5. Framework Class Library
It is a collection of classes, types, and API’s which forms the foundation of .Net framework and help to create multiple functions and different types of applications such as web, mobile application, desktop, etc. It promotes code reusability and simplifies the development of feature-rich applications using the .Net framework.
6. .Net Assemblies
These are self contained units of deployment and is the main building block of the .Net framework. It contains compiled data, metadata and resources which are needed to execute and run an application. It contains a small unit of logically compiled code in the CLI (Common Language Infrastructure) which is used for security, deployment and versioning. A complied .Net program generates metadata with MIL (Microsoft Intermediate Language) which is stored in assembly.
7. XML Web Services
XML web services are developed using Windows Communication Foundation or ASP.NET web services. It provides a flexible and lightweight approach to create XML web services with the help of SOAP protocol and XML serialization.
8. Window Services
It provides a way to create long running background processes which run on Windows operating system. Developers can use the scalability and power of windows services to create reliable and efficient background processes for business automation needs.
Design Principles of .Net
The .Net framework is created using a set of design principles which ensures that .Net applications are scalable, interoperable and robust. Some of the key design principles of .Net are:
Interoperability: It is a basic principle of .Net which enables easy communication and integration among different systems, components and languages. The CLS (Common Language Specification) and CLI (Common Language Infrastructure) defines a set of rules which provides language independence and interoperability among various components in the .Net ecosystem. With the help of these rules and standards, developers can create components in one language and use the same codebase with various other platforms.
Language Independence: .Net framework supports various programming languages which gives the developers the flexibility to select the language which best suits their preferences and needs. Various language like F#, Visual Basic .NET and C# are fully integrable with the .Net ecosystem. It allows the developers to exploit this integration power of the framework by allowing them to use their own preferred language.
Type Safety: Type safety prevents runtime errors and enhances code reliability. The Common Type System or CTS provides a set of rules for inheritance and type definition which ensures type safety. Type safety enables code correctness, reduces runtime exceptions and improves maintainability.
Portability: The .Net framework is portable and allows applications to run on different operating systems and architectures. With the help of .Net core, the portability of the .net applications gets enhanced as it supports platforms like Windows, macOS and Linux. Several Api’s provided by the Base Class Library allows applications to be developed once and deployed across multiple platforms with little or no modifications. Therefore, the reach of the application is increased and also helps in cross platform development of the application.
Security: Several security mechanisms are incorporated by the .Net framework thereby securing the application and the data. The CLR (Common Language Runtime) prevents unauthorized access to code and also restricts the actions which the code can perform based on the access granted to it. The framework uses encrypted Api’s which allows secure transmission of data and even protects the database(storage). Therefore, .Net helps in developing secure and safe applications.
Memory Management: CLR (Common Language Runtime) also handles the memory by using a garbage collector thereby preventing the developers from doing manual memory allocation and deallocation tasks. The garbage collector of CLR automatically identifies and frees memory which is not in use, thereby preventing memory leaks. This enhances the performance, stability and helps develop a robust application.
Performance: The .Net framework/Architecture includes many features and optimizations which helps in making high-performance applications. The Just-In-Time (JIT) compiler creates an optimized machine code from the intermediate language, thereby making the machine code to be easily executable by the target hardware. The framework also provides many optimisation techniques which help in boosting the performance of the architecture.
What are .NET programming languages?
.Net supports three programming languages namely:
C#: C# or C sharp is a cross platform, modern, type-safe and object oriented language. It has its roots from the C programming language which makes C# familiar to C++, Java and JavaScript. Most of the runtime libraries are written in C#. As C# is an object oriented language, it incorporates features from many other paradigms.
F#: F# or F sharp is a programming language which allows developers to develop easy, succinct, performant and robust code. F# majorly focuses on simplicity, elegance and power and is used by millions of developers. F# gets easily integrated with C# and offers full power of .Net.
Visual Basic: Visual Basic is an approachable language which offers a simple syntax which helps in creating object-oriented and type safe apps.
What is .NET runtime?
.NET runtime helps in running the compiled code. Code written in the .Net framework is known as Managed Code, and this running of compiled code is known as managed code execution. .Net runtime ensures platform independence. Common Language Runtime (CLR) functions like a virtual component of the .Net framework which executes different language programs like Visual Basic, C#, etc.
Whenever a .Net application is executed, the code is compiled into bytecode or Common intermediate language(CIL). The bytecode is taken and executed on the target machine with the help of .Net runtime. The JIT(Just-in-Time) compiler allows bytecode to compile into machine code at runtime in order to give optimal performance.
The .Net runtime is also responsible for memory allocation and garbage collection. The memory is allocated to objects automatically. This memory is also released whenever it is no longer in use. The .Net runtime also assures security measures. The source codes are executed safely. It also prevents and protects our system from any such operations that may be done by any unauthorized or malicious code.
Features of .Net
Some of the features of .Net are:
Cross Language Interoperability: Cross Language Interoperability means that code written in one language can be used by other languages. In other words, Language Interoperability allows a code written in one programming language to interact with code written in other programming languages. This helps in code reusability and thereby improving the efficiency of the code.
Security: The components in .Net are awarded with various degrees of trust which depend on many factors which includes their origin. This feature allows developers to keep an eye on operations like registry-access operations, file-access operations and much more. Windows was always criticised for its poor security however, Microsoft has immensely worked on the security of .Net thereby making it much more secure and efficient.
Resource Management: .Net does automatic resource management with the help of CLR(Common Language Runtime). The garbage collector of the CLR serves as an automatic resource manager. The garbage collector of CLR automatically identifies and frees memory which is not in use, thereby preventing memory leaks. This enhances the performance, stability and helps develop a robust application.
Type Safety: While executing the program, the type checker checks that all the objects, its references and values have a valid type. It also ensures that only valid operations are performed on the objects. Also the data structure used in .Net languages have the same layout which allows some code in one programming language to consume instances and types in other programming languages.
Side by Side execution: The .Net framework allows developers to deploy multiple versions of the application with help of assemblies. Assemblies are self-contained units of deployment and is the main building block of the .Net framework. It contains compiled data, metadata and resources which are needed to execute and run an application. The CLR helps to run multiple applications side by side.
Libraries in .Net
Some of the most frequently used Libraries in .Net are:
AutoMapper: This is an object-object mapper library in .NET. This library solves complex problems by getting rid of code which is mapped from one object to another.
FluentValidation: As the name suggests, FluentValidation is a popular validation library present in the .Net ecosystem. With the help of this library, developers can define validation rules and techniques which even includes conditional validation, asynchronous validation and cross validation. It uses lambda expressions and a fluent interface for creating validation rules.
Mediatr: This library helps in providing a simple way to do in process communication and messaging with little or no dependencies. It supports queries, commands, request and response, events and notifications, asynchronous and synchronous dispatching with C# generic variance. With the help of the query, developers can decouple receiver and sender requests and thereby allowing them to communicate via a mediator object.
Base Class Libraries: It is a fundamental library present in .Net which provides reusable classes and their types. It includes system.io for file input/output operations, system.net for networking, system.collections for data structures and algorithms and also system.security for functionality related to security.
Autofac: Autofac is a popular lightweight and flexible dependency injection container of the .Net framework which manages the dependencies between the classes. It allows the developers to manage and resolve object dependencies easily and efficiently so that when the applications grow in complexity and size they are easy to change. It also supports features like interception, component scanning and lifetime scopes thereby enabling the developers to create and build testable applications.
.Net Class Libraries: These libraries are the shared library concept for .Net which enables us to make components of the functions into modules which can be further used by applications. There are three types of .Net Class libraries namely:
Portable Class Libraries: These libraries are supported by multiple implementations of .Net and can still run with dependencies on a known execution environment. Whenever we choose an execution platform, a portable library needs to be created. Portable class libraries have access to some of the Api’s which can be used by apps and libraries which target multiple platforms.
Platform Specific Class Libraries: Unlike the portable libraries, platform libraries have all the Api’s related to a particular platform, but these Api’s can only be accessed by the apps and libraries which target that platform. As the name suggests, these libraries are specific to a platform and can only run on that specific platform. These libraries help in performing and also check for unnecessary conditional code.
.Net Standard Class Libraries: These libraries are like a combination of portable and platform libraries. These libraries merge the portable and platform libraries thereby providing the best of both. The .Net standard class libraries are supported by only those platforms which support its contract dependencies.
Difference Between .NET and ASP.NET Framework
Basis
.NET
ASP.NET Framework
Type
Development framework for building applications
Web application framework for building web applications
Key Components
Common Language Runtime (CLR), Class Library
ASP.NET Web Forms, ASP.NET MVC, ASP.NET Web API, etc.
Language Supported
Supports multiple languages (C#, VB.NET, etc.)
Same language support as .NET, plus server-side code in ASP.NET (C#, VB.NET)
Environment required
It can be used for standalone applications
Requires a web server environment (IIS)
Scope
Broad covers various application types
Focused on web applications
Differences Between .NET Core and .NET Framework
What is .NET Core?
It is an open source implementation of .Net which supports building applications that can run on Macos, Linux and Windows. It is modular and lightweight which allows developers to include only the necessary components in the applications. This reduces the application size and thereby boosting the performance. It provides a Command Line Interface (CLI) which allows developers to create, build, test and deploy applications. It includes technologies such as Xamarin.Forms, ASP.NET Core and Entity Framework Core.
What is .NET Framework?
It is the original implementation of .Net which focuses on development of windows-based applications. It supports the development of various types of applications like console applications, web applications, desktop applications and web services. It includes technologies like WCF, ASP.NET MVC, Windows Forms, ASP.NET Web Forms and ADO.NET. The .Net framework supports multiple programming languages. It uses a CIL (Common Intermediate Language) which allows code to be written in various languages to interoperate and share functionality.
Differences between.NET Core and .NET Framework?
Below are the differences between .Net core and framework.
Basis
.Net Core
.Net Framework
Open Source
It is open source.
Only some components of the .NET framework are open source.
Platform
It is the platform which supports frameworks like the Universal Windows Platform and ASP.NET Core.
It provides a complete development framework which has all the basic requirements for development of applications.
Cross-Platform
Based on the principle of “develop once, run anywhere”. It is compatible with various operating systems like Macos, Windows and Linux.
It was developed to support software on all operating systems but is only compatible with Windows operating systems.
Installation
It is packaged and installed individually since its cross-platform.
Installed as a single package for windows operating system.
Performance
Has high scalability and performance as compared to .NET framework.
Has less scalability and performance in comparison to .NET core.
Application Models
Some of the common application models of .net are:
1. ASP.NET
It is a web framework which is developed and designed by Microsoft. It helps in developing dynamic web applications and web services. It allows easy integration with HTML, CSS and Javascript. A popular design pattern in ASP.NET is ASP.NET MVC where MVC stands for Model View Controller. It divides the application into three components i.e. the Model which is the data and business logic, the user interface which is the View and the Controller which handles user interactions and controls the flow of the application.
2. .NET Framework
It is the original implementation of .Net which focuses on development of windows-based applications. It supports the development of various types of applications like console applications, web applications, desktop applications and web services. It includes technologies like WCF, ASP.NET MVC, Windows Forms, ASP.NET Web Forms and ADO.NET. The .Net framework supports multiple programming languages. It uses a CIL (Common Intermediate Language) which allows code to be written in various languages to interoperate and share functionality.
3. .NET Core
It is an open source implementation of .Net which supports building applications that can run on Macos, Linux and Windows. It is modular and lightweight which allows developers to include only the necessary components in the applications. This reduces the application size and thereby boosting the performance. It provides a Command Line Interface (CLI) which allows developers to create, build, test and deploy applications. It includes technologies such as Xamarin.Forms, ASP.NET Core and Entity Framework Core.
4. Xamarin
A cross platform app development framework which allows developers to write a single codebase in C# and share the same codebase to different platforms. It allows developers to build mobile applications for Windows and iOS using C# and the .NET platform. Xamarian easily integrates with Visual Studio Code thereby providing a powerful and familiar toolset for development. Xamarin provides Xamarin.Essentials library which provides a collection of cross-platform API’s which handles tasks like file access, connectivity, geolocation etc.
The .Net framework is a software development framework which focuses on development of windows-based applications. It supports the development of various types of applications like console applications, web applications, desktop applications and web services. The .Net framework supports multiple programming languages like C#, F# and Visual Basic.
Is .NET Framework the same as C#?
No, .NET framework and C# are completely different. While C# is a programming language, .NET framework is a software framework. .NET framework supports programming languages like C# , F# and Visual Basic.
Is .NET framework frontend or backend?
The framework can be used for both i.e. frontend as well as backend. However, it is majorly used for backend development. For frontend, it offers technologies like Windows Forms and WPF (Windows Presentation Foundation) and for backend, it allows the application to be built on ASP.NET MVC(Model View Controller) or ASP.NET Web Forms.
What is Basic .NET Framework?
The .NET framework is a software framework which includes two components - CLR (Common Language Runtime) and FCL (Framework Class Library). CLR provides a run-time environment that runs the code while FCL is a collection of reusable interfaces, classes and methods which are a part of the .Net framework.
Conclusion
In conclusion, .Net offers a versatile and robust development of applications. As it supports multiple programming languages like C#, F# and Visual Basic, it gives the developers a flexibility to choose a language which best suits their preferences and needs. It also provides an extensive set of frameworks and libraries which simplifies and accelerates the development process.
Happy Coding!
Live masterclass
Land an SDE Role at Google: Master DSA the smart way
by Saurav Prateek, SDE2@Google
19 Sep, 2024
01:30 PM
Become a Data Analyst at MAANG: Learn PowerBI for Data visualization
by Megna Roy, Senior Data Analyst @Amazon
17 Sep, 2024
01:30 PM
Learn Advanced Excel: Ace Data Analytics Interview
by Megna Roy, Data Analyst @ Amazon
15 Sep, 2024
06:30 AM
Land an SDE Role at Google: Master DSA the smart way
by Saurav Prateek, SDE2@Google
19 Sep, 2024
01:30 PM
Become a Data Analyst at MAANG: Learn PowerBI for Data visualization