.
NET Framework
From Wikipedia, the free encyclopedia
".NET" redirects here. For the top-level Internet domain, see .net. For other uses, see .NET
(disambiguation).
.NET Framework
.NET Framework component stack
Developer(s) Microsoft
Initial release 13 February 2002; 15 years ago
Stable release 4.7 / 5 April 2017; 5 months ago[1]
Operating system Windows 98 or later, Windows NT 4.0 or later
Type Software framework
License Mixed; see § Licensing
Website [Link]/net
.NET Framework (pronounced dot net) is a software framework developed by Microsoft that runs
primarily onMicrosoft Windows. It includes a large class library named Framework Class
Library (FCL) and provideslanguage interoperability (each language can use code written in other
languages) across several programming languages. Programs written for .NET Framework execute
in a software environment (in contrast to a hardwareenvironment) named Common Language
Runtime (CLR), an application virtual machine that provides services such as security, memory
management, and exception handling. (As such, computer 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. Programmers produce
software by combining their source code with .NET Framework and other libraries. The framework is
intended to be used by most new applications created for the Windows platform. Microsoft also
produces an integrated development environment largely for .NET software called Visual Studio.
.NET Framework began as proprietary software, although the firm worked to standardize the
software stack almost immediately, even before its first release. Despite the standardization efforts,
developers, mainly those in the free and open-source software communities, expressed their unease
with the selected terms and the prospects of any free and open-source implementation, especially
regarding software patents. Since then, Microsoft has changed .NET development to more closely
follow a contemporary model of a community-developed software project, including issuing an
update to its patent promising to address the concerns.
.NET Framework led to a family of .NET platforms targeting mobile computing, embedded devices,
alternativeoperating systems, and web browser plug-ins. A reduced version of the framework, .NET
Compact Framework, is available on Windows CE platforms, including Windows Mobile devices
such as smartphones. .NET Micro Framework is targeted at very resource-constrained embedded
devices. Silverlight was available as a web browser plugin. Mono is available for many operating
systems and is customized into popular smartphone operating systems (Android and iOS) and game
engines. .NET Core targets the Universal Windows Platform(UWP), and cross-platform and cloud
computing workloads.
Design principle[edit]
Interoperability[edit]
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 [Link] and [Link] 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[edit]
.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[edit]
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 (with or without type inference). 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[edit]
While Microsoft has never implemented the full framework on any system except Microsoft
Windows, it has engineered the framework to be cross-platform,[43] and implementations are available
for other operating systems (see Silverlight and § Alternative implementations). Microsoft submitted
the specifications for CLI (which includes the core class libraries, CTS, and CIL), [44][45][46] C#,[47] and C+
+/CLI[48] to both Ecma International (ECMA) and International Organization for Standardization(ISO),
making them available as official standards. This makes it possible for third parties to create
compatible implementations of the framework and its languages on other platforms.
Security[edit]
.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.[49]
[50]
.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.[51] 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 DotfuscatorCommunity Edition with Visual
Studio .NET since 2002.[b] Third-party obfuscation tools are also available from vendors such
as VMware, V.i. Labs, Xenocode, andRed Gate Software. Method-level encryption tools for .NET
code are available from vendors such as SafeNet.
Memory management[edit]
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. It is a non-deterministic, compacting, mark-and-sweep garbage
collector. 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.[52] 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.[52] This is the mark phase.[53]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.[52][53] Any reference to an object invalidated by moving the object is updated
by GC to reflect the new location.[53] 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.[54]
GC used by .NET Framework is also generational.[55] Objects are assigned a generation. Newly
created objects are tagged Generation 0. Objects that survive a garbage collection are
tagged Generation 1. Generation 1 objects that survive another collection are Generation 2. The
framework uses up to Generation 2 objects.[55] 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.[55] Thus, by eliminating older (and thus more likely to
survive a collection) objects from the scope of a collection run, fewer objects need checking and
compacting.[55]
Performance[edit]
When an application is first launched, the .NET Framework compiles the CIL code into executable
code using its just-in-time compiler, and caches the executable program into the .NET Native Image
Cache.[56][57] Due to caching, the application launches faster for subsequent launches, although the
first launch is usually slower. To speed up the first launch, developers may use the Native Image
Generator utility to manually ahead-of-time compile and cache any .NET application.[57]
The garbage collector, which is integrated into the environment, can introduce unanticipated delays
of execution over which the developer has little direct control. "In large applications, the number of
objects that the garbage collector needs to work with can become very large, which means it can
take a very long time to visit and rearrange all of them."[58]
.NET Framework provides support for calling Streaming SIMD Extensions (SSE) via managed
code from April 2014 in Visual Studio 2013 Update 2. However, Monohas provided support
for SIMD Extensions as of version 2.2 within the [Link] namespace in 2009.[59] Mono's lead
developer Miguel de Icaza has expressed hope that this SIMD support will be adopted by CLR's
ECMA standard.[60] Streaming SIMD Extensions have been available in x86 CPUs since the
introduction of thePentium III. Some other architectures such as ARM and MIPS also have SIMD
extensions. In case the CPU lacks support for those extensions, the instructions are simulated in
software.[61]
Alternative implementations[edit]
.NET Framework is the predominant implementation of .NET technologies. Other implementations
for parts of the framework exist. Although the runtime engine is described by an ECMA-ISO
specification, other implementations of it may be encumbered by patent issues; ISO standards may
include the disclaimer, "Attention is drawn to the possibility that some of the elements of this
document may be the subject of patent rights. ISO shall not be held responsible for identifying any or
all such patent rights."[62] It is harder to develop alternatives to FCL, which is not described by an
open standard and may be subject to copyright restrictions. Also, parts of FCL have Windows-
specific functions and behavior, so implementation on non-Windows platforms can be problematic.
Some alternative implementations of parts of the framework are listed here.
.NET Micro Framework is a .NET platform for extremely resource-constrained devices. It
includes a small version of CLR and supports development in C# (though some developers were
able to use [Link],[63] albeit with an amount of hacking, and with limited functionalities) and
debugging (in an emulator or on hardware), both using Microsoft Visual Studio. It also features a
subset of .NET Framework Class Library (about 70 classes with about 420 methods),
a GUI framework loosely based on WPF, and additional libraries specific to embedded
applications.
.NET Core is an alternative Microsoft implementation of the managed code framework; it has
similarities with .NET Framework and even shares some API, but is designed based on different
sets of principles: It is cross-platform and free and open-source.
Mono is an implementation of CLI and FCL, and provides added functions. It is dual-
licensed as free and proprietary software. It includes support for [Link], [Link], and
Windows Forms libraries for a wide range of architectures and operating systems. It also
includes C# and [Link] compilers.
[Link] (part of DotGNU) provides an implementation of CLI, parts of FCL, and a C#
compiler. It supports a variety of CPUs and operating systems. The project was discontinued,
with the last stable release in 2009.
Microsoft Shared Source Common Language Infrastructure is a non-free implementation of
CLR. However, the last version runs on Windows XP SP2 only, and has not been updated since
2006. Thus, it does not contain all features of version 2.0 of .NET Framework.
CrossNet[64] is an implementation of CLI and parts of FCL. It is free software using an open
source MIT License.
.NET Core[edit]
.NET Core is a cross-platform free and open-source managed software framework similar to .NET
Framework. It consists of CoreCLR, a complete cross-platform runtime implementation of CLR, the
virtual machine that manages the execution of .NET programs. CoreCLR comes with an
improved just-in-time compiler, called RyuJIT.[65][c] .NET Core also includes CoreFX, which is a
partial fork of FCL.[67] While .NET Core shares a subset of .NET Framework APIs, it comes with its
own API that is not part of .NET Framework.[68] Further, .NET Core contains CoreRT, the .NET Native
runtime optimized to be integrated into AOT compiled native binaries. A variant of the .NET Core
library is used for UWP.[69] .NET Core's command-line interface offers an execution entry point for
operating systems and provides developer services like compilation and package management. [70]
.NET Core supports four cross-platform scenarios: [Link] Core web apps, command-line apps,
libraries, and Universal Windows Platform apps. It does not implement Windows
Forms or WPF which render the standard GUI for desktop software on Windows.[68][71] .NET Core is
also modular, meaning that instead of assemblies, developers work with NuGet packages.
Unlike .NET Framework, which is serviced using Windows Update, .NET Core relies on its package
manager to receive updates.[68][71]
.NET Core 1.0 was released on 27 June 2016,[72] along with Visual Studio 2015 Update 3, which
enables .NET Core development.[73] .NET Core 1.0.4 and .NET Core 1.1.1 were released along
with .NET Core Tools 1.0 and Visual Studio 2017 on 7 March 2017.[74]
.NET Core 2.0 was released on 14 August 2017 along with Visual Studio 2017 15.3, [Link] Core
2.0, and Entity Framework Core 2.0.[75]
Licensing[edit]
Microsoft managed code frameworks and their components are licensed as follows:
Component License
.NET Framework (redistributable package) Proprietary software[76]
Reference source code of .NET Framework 4.5 and Microsoft Reference License (Ms-RSL[a])[7]
earlier [77]
Reference source code of .NET Framework 4.6 MIT License[78]
Mono MIT License[79]
.NET Core
MIT License[80]
CoreFX, CoreCLR and CLI
.NET Micro Framework Apache License 2.0[81]
.NET Compiler Platform (codename "Roslyn") Apache License 2.0[82]
[Link] MVC, Web API and Web Pages (Razor) Apache License 2.0[83]
[Link] Core Apache License 2.0[84]
[Link] Ajax Control Toolkit BSD License[85]
[Link] SignalR Apache License 2.0[86]
Entity Framework Apache License 2.0[87]
NuGet Apache License 2.0[88]