Chapter 1.1 - Introduction To .NET Framework and DOT NET

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 9
At a glance
Powered by AI
The key takeaways are that .NET is a developer platform made up of tools, programming languages and libraries for building different types of applications. The main implementations of .NET discussed are .NET Framework, .NET Core and Xamarin/Mono.

The two major components of .NET Framework are the Common Language Runtime (CLR) and the .NET Framework Class Library. The CLR handles running applications and provides services like thread management and garbage collection. The Class Library provides a set of common APIs and types.

Some of the main differences discussed are that .NET Core is open source, cross-platform and focuses on performance/scalability while .NET Framework is compatible only with Windows and includes features like code access security.

Unit-1: Introduction to .NET Framework and C#.

NET

Chapter 1

.NET and .NET Framework


.NET is a developer platform made up of tools, programming languages, and libraries for
building many different types of applications.

There are various implementations of .NET. Each implementation allows .NET code to
execute in different places—Linux, macOS, Windows, iOS, Android, and many more.

1. .NET Framework is the original implementation of .NET. It supports running


websites, services, desktop apps, and more on Windows.
2. .NET is a cross-platform implementation for running websites, services, and
console apps on Windows, Linux, and macOS. .NET is open source on
GitHub. .NET was previously called .NET Core.

The .NET Core Framework composed of the following parts:

 CLI Tools: A set of tooling for development and deployment.


 Roslyn: Language compiler for C# and Visual Basic
 CoreFX: Set of framework libraries.
 CoreCLR: A JIT based CLR (Command Language Runtime).
3. Xamarin/Mono is a .NET implementation for running apps on all the major
mobile operating systems, including iOS and Android.

.NET Standard is a formal specification of the APIs that are common across .NET
implementations. This allows the same code and libraries to run on different
implementations.

Component Based Technology


1
Unit-1: Introduction to .NET Framework and C#.NET

Features of .NET Core and .NET Framework


S.No Basis .NET Core .NET Framework

1 Platform or ASP.NET Core and the Universal The framework provides all the basic
Framework Windows Platform rely requirements for the development
of applications such as UI, DB
connectivity, services, APIs, etc.

2 Open-Source .NET Core is an open-source The.Net Framework includes certain


platform. open source components.
3 Cross-Platform It is compatible with a variety of .NET Framework is compatible with
operating systems, including Windows OS(operating system) only
Windows, Linux, and Mac OS.
4 Application The Application Model of .Net Core The Application Model of the .NET
models includes ASP.NET and windows Framework includes WinForms,
universal apps. ASP.NET, and WPF.
5 Installation .Net Core is the cross-platform; .NET Framework has a single
hence it needs to be installed packaged installation and runtime
independently. environment for windows.
6 Microservices .NET Core has support for .NET Framework it does not allow
support microservices. for the construction and deployment
of microservices in multiple
languages.

7 Performance and .NET core provides high scalability .NET Framework is less scalable and
Scalability and performance in comparison provides low performance in
to .NET Framework because of its comparison to .NET Core.
architecture.

8 Security Feature such as Code Access .NET Framework has this feature
Security is not present in .NET core called code access security.
9 Focus on devices .NET Core focuses to develop apps .NET Framework is limited to
in a variety of domains like gaming, window OS.
mobile, IoT, AI, etc.
10 CLI Tools For all platforms,.NET Core provides .NET Framework is too heavy for CLI.
a very lightweight CLI( Command
Line Interface).
12 Deployment .NET Core provides a solid and When the updated version is
Model adaptable deployment model. released it is first deployed on the
internet information service only.
13 Packaging and .NET Core is shipped as a collection All the libraries of the .NET
shipping of Nuggets packages. Framework are packed and shipped
together.

Architecture of .NET Framework

Component Based Technology


2
Unit-1: Introduction to .NET Framework and C#.NET

The two major components of .NET Framework are the Common Language Runtime and
the .NET Framework Class Library.

 The Common Language Runtime (CLR) is the execution engine that handles


running applications. It provides services like thread management, garbage
collection, type-safety, exception handling, and more.
 The Class Library provides a set of APIs and types for common functionality. It
provides types for strings, dates, numbers, etc. The Class Library includes APIs for
reading and writing files, connecting to databases, drawing, and more.

.NET applications are written in the C#, F#, or Visual Basic programming language. Code
is compiled into a language-agnostic Common Intermediate Language (CIL). Compiled
code is stored in assemblies—files with a .dll or .exe file extension.

When an app runs, the CLR takes the assembly and uses a just-in-time compiler (JIT) to
turn it into machine code that can execute on the specific architecture of the computer it
is running on.

Component Based Technology


3
Unit-1: Introduction to .NET Framework and C#.NET

Managed code and CLR


.Net Framework provides runtime environment called Common Language
Runtime (CLR). It provides an environment to run all the .Net Programs. The code which
runs under the CLR is called as Managed Code. Programmers need not to worry on
managing the memory if the programs are running under the CLR as it provides memory
management and thread management.

Programmatically, when our program needs memory, CLR allocates the memory for
scope and de-allocates the memory if the scope is completed.

Managed code uses CLR which in turns looks after your applications by managing
memory, handling security, allowing cross - language debugging, and so on.

Language Compilers (e.g. C#, VB.Net, J#) will convert the Code/Program to Microsoft
Intermediate Language (MSIL) intern this will be converted to Native Code by CLR.

There are currently over 11 different language compilers being built by Microsoft and
other companies also producing the code that will execute under CLR.

Intermediate Language (IL)
Common Intermediate Language (CIL), formerly called Microsoft Intermediate
Language (MSIL) or Intermediate Language (IL).

 The IL is used by the .NET Framework to generate machine-independent code as


the output of compilation of the source code written in any .NET programming
language.

Component Based Technology


4
Unit-1: Introduction to .NET Framework and C#.NET

 CIL instructions are executed by a CLI-compatible runtime environment such as


the Common Language Runtime. Languages which target the CLI compile to CIL.
 CIL is object-oriented, stack-based bytecode. Runtimes typically just-in-
time compile CIL instructions into native code.

Metadata
Metadata is binary information describing your program that is stored either in a
common language runtime portable executable (PE) file or in memory. When you
compile your code into a PE file, metadata is inserted into one portion of the file, and
your code is converted to Microsoft intermediate language (MSIL) and inserted into
another portion of the file.

Every type and member that is defined and referenced in a module or assembly is
described within metadata. When code is executed, the runtime loads metadata into
memory and references it to discover information about your code's classes, members,
inheritance, and so on.

Metadata describes every type and member defined in your code in a language-neutral
manner. Metadata stores the following information:

 Description of the assembly.


 Identity (name, version, culture, public key).
 The types that are exported.
 Other assemblies that this assembly depends on.
 Security permissions needed to run.
 Description of types.
 Name, visibility, base class, and interfaces implemented.
 Members (methods, fields, properties, events, nested types).
 Attributes.
 Additional descriptive elements that modify types and members.

Just-In-Time compiler (JIT)


 The JIT compiler translates the MSIL code of an assembly to native code and
uses the CPU architecture of the target machine to execute a .NET application.
 It also stores the resulting native code so that it is accessible for subsequent
calls.
 If a code executing on a target machine calls a non-native method, the JIT
compiler converts the MSIL of that method into native code.
 The JIT compiler also enforces type-safety in the runtime environment of
the .NET Framework.

Component Based Technology


5
Unit-1: Introduction to .NET Framework and C#.NET

 It checks for the values that are passed to parameters of any method.
The following are the various types of JIT compilation in .NET:
Pre - JIT
 In Pre-JIT compilation, complete source code is converted into native code in
a single cycle (i.e. compiles the entire code into native code in one stretch)
 This is done at the time of application deployment.
 In .Net it is called "Ngen.exe"
Econo - JIT
 In Econo-JIT compilation, the compiler compiles only those methods that are
called at run time.
 After execution of this method the compiled methods are removed from
memory.
Normal - JIT
 In Normal-JIT compilation, the compiler compiles only those methods that are
called at run time.
 After executing this method, compiled methods are stored in a memory
cache.
 Now further calls to compiled methods will execute the methods from the
memory cache.
  
Automatic Memory Management
Automatic memory management is made possible by Garbage Collection in .NET
Framework. When a class object is created at runtime, certain memory space is allocated
to it in the heap memory.

However, after all the actions related to the object are completed in the program, the
memory space allocated to it is a waste as it cannot be used.

In this case, garbage collection is very useful as it automatically releases the memory
space after it is no longer required.

Garbage collection will always work on Managed Heap and internally it has an Engine
which is known as the Optimization Engine.

Component Based Technology


6
Unit-1: Introduction to .NET Framework and C#.NET

.Net Assembly
Microsoft .Net Assembly is a logical unit of code that contains code which the Common
Language Runtime (CLR) executes. It is the smallest unit of deployment of a .net
application and it can be a .dll or an exe. Assembly is really a collection of types and
resource information that are built to work together and form a logical unit of
functionality. It includes both executable application files that you can run directly from
Windows without the need for any other programs (.exe files), and libraries (.dll files) for
use by other applications.

Assemblies are the building blocks of .NET Framework applications. During the compile
time Metadata is created with Microsoft Intermediate Language (MSIL) and stored in a
file called Assembly Manifest. Both Metadata and Microsoft Intermediate Language
(MSIL) together wrapped in a Portable Executable (PE) file. Assembly Manifest contains
information about itself. This information is called Assembly Manifest, it contains
information about the members, types, references and all the other data that the runtime
needs for execution.

Every Assembly you create contains one or more program files and a Manifest. There are
two types program files: Process Assemblies (EXE) and Library Assemblies (DLL). Each
Assembly can have only one entry point (that is, DllMain, WinMain, or Main).

We can create two types of Assembly:

1. Private Assembly

2. Shared Assembly

Component Based Technology


7
Unit-1: Introduction to .NET Framework and C#.NET

A private Assembly is used only by a single application, and usually it is stored in that
application's install directory. A shared Assembly is one that can be referenced by more
than one application. If multiple applications need to access an Assembly, we should add
the Assembly to the Global Assembly Cache (GAC). There is also a third and least known
type of an assembly: Satellite Assembly. A Satellite Assembly contains only static objects
like images and other non-executable files required by the application.

.NET Objects
An object is a combination of code and data that can be treated as a unit. An object can
be a piece of an application, like a control or a form. An entire application can also be an
object.

When you create an application in Visual Basic, you constantly work with objects. You
can use objects provided by Visual Basic, such as controls, forms, and data access
objects. You can also use objects from other applications within your Visual Basic
application. You can even create your own objects and define additional properties and
methods for them. Objects act like prefabricated building blocks for programs — they let
you write a piece of code once and reuse it over and over.

List of .NET Objects


 

 Microsoft CheckBox Control


 Microsoft DataGrid Control
 Microsoft DataGridView Control
 Microsoft DomainUpDown Control
 Microsoft LinkLabel Control
 Microsoft NumericUpDown Control
 Microsoft PropertyGrid Control
 Microsoft RadioButton Control
 Microsoft StatusStrip Control
 Microsoft ToolStrip Control

.NET Web services


A Web service, in the context of .NET, is a component that resides on a Web server and
provides information and services to other network applications using standard Web
protocols such as HTTP and Simple Object Access Protocol (SOAP).

.NET Web services provide asynchronous communications for XML applications that
operate over a .NET communications framework. They exist so that users on the Internet

Component Based Technology


8
Unit-1: Introduction to .NET Framework and C#.NET

can use applications that are not dependent on their local operating system or hardware
and are generally browser-based.
Web Service Technologies

 XML- Describes only data. So, any application that understands XML-regardless
of the application's programming language or platform has the ability to format
XML in a variety of ways (well-formed or valid).
 SOAP- Provides a communication mechanism between services and applications.
 WSDL- Offers a uniform method of describing web services to other programs.
 UDDI- Enables the creation of searchable Web services registries.

Component Based Technology


9

You might also like