Introduction To .Net Frameworknew
Introduction To .Net Frameworknew
NET
Framework
Unit 1
What is .NET ?
NET is a free and open-source software development
platform developed by Microsoft.
In April 2019, Microsoft released .NET Framework 4.8, the last major version of
the framework as a proprietary offering, followed by .NET Framework 4.8.1 in
August 2022 with Visual Studio 2019.
history and evolution of the DOT NET
Framework
Before DOT NET Framework COM was there
What is COM?
COM stands for Component Object Model. The COM is one of the
Microsoft Frameworks. Using this Framework, we can develop Windows
Applications (Desktop or Standalone Applications for Windows OS) as
well as Web Applications. In earlier COM, VB is the programming
language that is used to implement Windows applications and ASP is
the technology used to implement web applications.
Note: There are many programming languages (more than 40), but only a small
amount of the .NET languages are provided or supported by Microsoft - for
example, Visual Basic .NET, C#, and more.
.NET Framework Objectives
To ensure that code based on the .NET Framework can
integrate with any other code
All programs written for .NET Framework are executed by the CLR.
The application written in the languages like C#, VB.NET etc. are
always aimed at runtime environment services to manage the
execution and the code written in these types of languages are
known as managed code.
Managed code
Advantages
It improves the security of the application like when you use runtime
environment, it automatically checks the memory buffers to guard
against buffer overflow.
It implement the garbage collection automatically.
It also provides runtime type checking/dynamic type checking.
It also provides reference checking which means it checks whether
the reference point to the valid object or not and also check they are
not duplicate.
Disadvantages
The main disadvantage of managed language is that you are not
allowed to allocate memory directly, or you cannot get the low-level
access of the CPU architecture.
Unmanaged code
The code, which is developed outside .NET, Framework is known as
unmanaged code.
Applications that do not run under the control of the CLR are said to
be unmanaged
Unmanaged code compiles straight to machine code and directly
executed by the Operating System.
Unmanaged code does not get services like security and memory
management
All code compiled by traditional C/C++ compilers are Unmanaged
Code. COM components, ActiveX interfaces, and Win32 API functions
are examples of unmanaged code.
Unmanaged code
Advantages
It also provides direct access to the hardware.
It allows the programmer to bypass some parameters and
restriction that are used by the managed code framework.
Disadvantages
It does not provide security to the application.
Due to the access to memory allocation the issues related
to memory occur like memory buffer overflow, etc.
Error and exceptions are also handled by the programmer.
It does not focus on garbage collection.
Common Language Specification(CLS)
CLS stands for Common Language Specification and it is a subset of
CTS.
It defines a set of rules and restrictions that every language must follow
which runs under the .NET framework. The languages which follow
this set of rules are said to be CLS Compliant. In simple words, CLS
enables cross-language integration.
The CLS is a specification that defines the rules for supporting the
language integration in a certain way that the programs are written in
any language, still, it can interoperate with the one another seamlessly
while taking the full advantage of concepts such as exceptions
handling, inheritance, polymorphism, and other features accordingly.
These CLS rules and the specification are documented in the ECMA
proposed standard document.
Common Language Specification(CLS)
For example, one rule is that you cannot use multiple inheritances
within .NET Framework. As you know C++ supports multiple
inheritances but; when you will try to use that C++ code within C#, it is
not possible because C# doesn’t support multiple inheritances.
One another rule is that you cannot have members with the same
name with case difference only i.e. you cannot have to add() and
Add() methods. This easily works in C# because it is case-sensitive but
when you will try to use that C# code in VB.NET, it is not possible
because VB.NET is not case-sensitive.
Common Language Infrastructure(CLI)
Common Language Infrastructure is a standard developed by
Microsoft that allows the use of multiple different high-level languages
on different computer platforms without rewriting the code for any
specific architecture.
In simple terms, Common Language Infrastructure (CLI) enables an
application program written in any commonly-used programming
languages to be run on any operating system using a common runtime
program rather than a specific for every language.
The .NET FCL forms the base on which applications, controls and
components are built in .NET. It can be used for developing applications
such as:
console applications
Windows GUI applications
ASP.NET applications
Windows and Web services
workflow-enabled applications
service oriented applications using Windows Communication
XML Web services, etc.
FCL (Framework Class Library)
Common Type System (CTS)
CTS specifies guidelines for declaring , using and managing types at run time
CTS defines the basic data types that IL understands. Each .NET compliant
language should map its data types to these standard data types. This makes it
possible for the 2 languages to communicate with each other
.NET supports many languages and every language has its own data type.
One language cannot understand data types of another language.
For example: When we are creating an application in C#, we have int and
when we are creating an application in VB .NET, we have an integer. Here
CTS comes into play -- after the compilation, CTS converts int and
integer into the int32 structure.
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.
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.
Assemblies
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.
Assemblies are of two types:
Static assemblies-they are stored in the PE files on disk
Strong name info The public key from the publisher if the assembly has been given a
strong name.
List of all files in Contains hash token and name of each file contained in assembly
assembly
Type reference Information used by the runtime to map a type reference to the file
information that contains its declaration and implementation.
This means that you can have multiple versions of the runtime,
and multiple versions of applications and components that use
a version of the runtime, on the same computer at the same
time.