Chapter 1.1 - Introduction To .NET Framework and DOT NET
Chapter 1.1 - Introduction To .NET Framework and DOT NET
Chapter 1.1 - Introduction To .NET Framework and DOT NET
NET
Chapter 1
There are various implementations of .NET. Each implementation allows .NET code to
execute in different places—Linux, macOS, Windows, iOS, Android, and many more.
.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.
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.
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.
The two major components of .NET Framework are the Common Language Runtime and
the .NET Framework Class Library.
.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.
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).
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:
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.
.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).
1. Private Assembly
2. Shared Assembly
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.
.NET Web services provide asynchronous communications for XML applications that
operate over a .NET communications framework. They exist so that users on the Internet
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.