.Net Framework
.Net Framework is a Software framework
developed by Microsoft that runs primarily on Windows.
.Net provides includes a large class library
called Framework Class Library(FCL).
Programs written in for .net framework execute in software environment named Common Language runtime(CLR) - an application virtual machine that
provides services such as security, memory
management, and exception handling. Code written using .NET
Framework is called "Managed
Code". FCL and CLR together constitute .NET Framework. FCL
provides user interface, data access, database connectivity, cryptography, web application development,
numeric algorithms,
and network communications
.Net Compact Framework – A reduced version of
framework is available is available on Windows CE platforms
like smartphones.
.NET Micro Framework is targeted at very
resource-constrained embedded devices.
.NET Core
targets the Universal Windows Platform (UWP),
and cross-platform and cloud computing workloads.
Architecture
Common Language Infrastructure:
Common Language Infrastructure (CLI) provides a language-neutral
platform for application development and execution. By implementing the core
aspects of .NET Framework within the scope of CLI, these functions will not be
tied to one language but will be available across the many languages supported
by the framework.
Common Language Runtime:
It serves as the execution engine of .NET Framework and offers
many services such as memory
management, type safety, exception handling, garbage collection,
security and thread management. All programs written for .NET Framework are executed by the CLR.
Programs written for .NET Framework are compiled into Common
Intermediate Language code (CIL). During execution, an
architecture-specific just-in-time compiler (JIT) turns
the CIL code into machine code.
Assemblies
Compiled CIL code is stored in CLI assemblies.
Assemblies are stored in Portable Executable (PE) file format,
common on Windows platform for all dynamic-link library (DLL) and executable EXE files. Each
assembly consists of one or more files, one of which must contain a manifest
bearing the metadata for the assembly. The complete name of an assembly
contains its simple text name, version number, culture, and public key token.
Class library
.NET Framework includes a set of standard class
libraries. The class library is organized in a hierarchy of namespaces.
Most of the built-in application programming interfaces (APIs)
are part of either System.* or Microsoft.* namespaces.
These class libraries implement many common functions, such as file reading and
writing, database interaction, and XML document manipulation. The class
libraries are available for all CLI compliant languages. The class library is
divided into two parts : Base Class Library (BCL) and Framework Class Library (FCL).
BCL includes a small subset of the entire class library and is
the core set of classes that serve as the basic API of CLR for .NET
Framework most classes considered being part of BCL reside in mscorlib.dll, System.dll and System.Core.dll.
FCL is a superset of BCL and refers to the entire class library
that ships with .NET Framework. It includes an expanded set of libraries,
including the Windows Forms, ASP.NET,
and Windows Presentation Foundation (WPF)
but also extensions to the base class libraries ADO.NET, Language Integrated Query (LINQ), Windows Communication Foundation (WCF),
and Workflow Foundation (WF). FCL is much
larger in scope than standard libraries for languages like C++,
and comparable in scope to standard libraries of Java.
Microsoft introduced the concept of Portable Class Libraries
(PCL) allowing a consuming library to run on more than one platform. With the
further proliferation of .NET platforms, the PCL approach failed to scale (PCLs
are defined intersections of API surface between two or more platforms).
NuGet is
the package manager for all .NET platforms. It is used to retrieve third-party
libraries into a .NET project with a global library feed at NuGet.org.
App models
.NET Framework supports Console, Windows Forms, Windows Presentation Foundation, ASP.NET and ASP.NET Core apps by
default.
Design
principles
Interoperability
Because computer systems commonly require interaction between
newer and older applications, .NET Framework provides means to access functions
implemented in newer and older programs that execute outside .NET environment. Access to Component Object Model (COM) components is
provided
in System.Runtime.InteropServices and System.EnterpriseServices namespaces
of the framework. Access to other functions is via Platform Invocation Services (P/Invoke).
Access to .NET functions from native applications is via reverse P/Invoke
function.
Language
independence
.NET Framework introduces a Common Type System (CTS) that defines
all possible data types and programming constructs supported by CLR
and how they may or may not interact with each other conforming to CLI
specification. Because of this feature, .NET Framework supports the exchange of
types and object instances between libraries and applications written
using any conforming .NET language.
Type
safety
CTS and the CLR used in .NET Framework also enforce type safety.
This prevents ill-defined casts, wrong method invocations, and memory size
issues when accessing an object. This also makes most CLI languages statically typed.
However, starting with .NET Framework 4.0, the Dynamic Language Runtime extended the
CLR, allowing dynamically typed languages to be implemented atop the CLI.
Portability
While Microsoft has never implemented the full framework on any
system except Microsoft Windows, it has engineered the framework to be
cross-platform and implementations are available for other operating
systems. This makes it possible for third parties to create compatible
implementations of the framework and its languages on other platforms.
Security
.NET Framework has its own security mechanism with two general
features: Code Access Security (CAS), and validation
and verification. CAS is based on evidence that is associated with a specific
assembly. Typically, the evidence is the source of the assembly (whether it is
installed on the local machine or has been downloaded from the Internet). CAS
uses evidence to determine the permissions granted to the code. Other code can
demand that calling code be granted a specified permission. The demand causes
CLR to perform a call stack walk: every assembly of each method in the call
stack is checked for the required permission; if any assembly is not granted the
permission a security exception is thrown.
Managed CIL bytecode is easier to reverse-engineer than native code,
unless obfuscated. .NET decompiler programs
enable developers with no reverse-engineering skills to view the source code
behind unobfuscated .NET assemblies. In contrast, apps compiled to native
machine code are much harder to reverse-engineer, and source code is almost never
produced successfully, mainly because of compiler optimizations and lack
of reflection.[56] This
creates concerns in the business community over the possible loss of trade secrets and
the bypassing of license control mechanisms. To mitigate this, Microsoft has
included Dotfuscator Community Edition with Visual Studio .NET since 2002.[b] Third-party
obfuscation tools are also available from vendors such as VMware, V.i. Labs, Turbo,
and Red Gate Software. Method-level encryption
tools for .NET code are available from vendors such as SafeNet.
Memory
management
CLR frees the developer from the burden of managing memory
(allocating and freeing up when done); it handles memory management itself by
detecting when memory can be safely freed. Instantiations of .NET types
(objects) are allocated from the managed heap; a pool of memory managed by CLR.
As long as a reference to an object exists, which may be either direct, or via
a graph of objects, the object is considered
to be in use. When no reference to an object exists, and it cannot be reached
or used, it becomes garbage, eligible for collection.
.NET Framework includes a garbage collector (GC)
which runs periodically, on a separate thread from the application's thread, that
enumerates all the unusable objects and reclaims the memory allocated to them.
GC runs only when a set amount of memory has been used or there is enough
pressure for memory on the system. Since it is not guaranteed when the
conditions to reclaim memory are reached, GC runs are non-deterministic. Each .NET application
has a set of roots, which are pointers to objects on the managed heap (managed
objects). These include references to static objects and objects defined as
local variables or method parameters currently in scope, and objects referred
to by CPU registers. When GC runs, it pauses the application and then, for
each object referred to in the root, it recursively enumerates
all the objects reachable from the root objects and marks them as reachable. It
uses CLI metadata and reflection to
discover the objects encapsulated by an object, and then recursively walk them.
It then enumerates all the objects on the heap (which were initially allocated
contiguously) using reflection. All objects not marked as reachable are
garbage. This is the mark phase. Since the memory held by
garbage is of no consequence, it is considered free space. However, this leaves
chunks of free space between objects which were initially contiguous. The
objects are then compacted together to make free space on the managed
heap contiguous again. Any reference to an object invalidated by moving
the object is updated by GC to reflect the new location. The application
is resumed after garbage collection ends. The latest version of .NET framework
uses concurrent garbage collection along with user code, making pauses
unnoticeable, because it is done in the background
The garbage collector used by .NET Framework is also generational Objects
are assigned a generation. Newly created objects are tagged Generation
0. Objects that survive one garbage collection are tagged Generation 1.
Generation 1 objects that survive another collection are Generation 2. The
framework uses up to Generation 2 objects. Higher generation objects are
garbage collected less often than lower generation objects. This raises the efficiency
of garbage collection, as older objects tend to have longer lifetimes than
newer objects. By ignoring older objects in most collection runs, fewer
checks and compaction operations are needed in total.
Source: https://en.wikipedia.org/wiki/.NET_Framework
Comments
Post a Comment