What is Microsoft .
Net Framework
The Microsoft .Net Framework is a platform that provides tools and
technologies you need to build Networked Applications as well as
Distributed Web Services and Web Applications. The .Net Framework
provides the necessary compile time and run-time foundation to build
and run any language that conforms to the Common Language
Specification (CLS).The main two components of .Net Framework
are Common Language Runtime (CLR) and .Net Framework Class
Library (FCL).
The Common Language Runtime (CLR) is the runtime environment of
the .Net Framework , that executes and manages all running code like
a Virtual Machine . The .Net Framework Class Library (FCL) is a huge
collection of language-independent and type-safe reusable classes. The
.Net Framework Class Libraries (FCL) are arranged into a logical
grouping according to their functionality and usability is called
Namespaces.
.Net Framework Architecture
The .Net Framework Architecture is the programming model for the
.NET platform. It provides a managed execution environment, simplified
development and deployment and integration with a wide variety of
programming languages. The .NET Framework class library (FCL) is a
comprehensive, object-oriented collection of reusable types that you can
use to develop applications. The common language runtime (CLR) is
the core runtime engine for executing applications in the .NET
Framework. The CLR is fully protected from the outside environment and
highly optimized within, taking advantage of the services that the CLR
provides such as security, performance, deployment facilities,
and memory management , including garbage collection.
Design Features Of .NET Framework
The principal design features of Microsoft .NET Framework are:
▪ Interoperability
▪ Portability
▪ Security
▪ Language independence
▪ Type safety
▪ Memory management
Interoperability
Language interoperability is the ability of code to interact with code that
is written using a different programming language. It can help maximize
code reuse and, therefore, improve the efficiency of the development
process. The .NET components can communicate with the existing
COM components without migrating to those components into .NET.
That means, this feature is a great help to reduce the migration cost and
time. PIAs (Primary Interop Assembly) provide the information that
supports interoperability between .NET and COM.
Portability
While Microsoft has never implemented the full framework on any
operating system except Microsoft Windows, it has engineered the
framework to be cross-platform , and implementations are available for
other operating systems. Portable class libraries can help you reduce the
time and costs of developing and testing code. The Portable Class
Library project type in Visual Studio environment helps you build cross-
platform apps and libraries for Microsoft platforms quickly and easily.
You can use this project type to write and build portable .NET
Framework assemblies , and then reference those assemblies from apps
that target other platforms such as the .NET Framework, iOS, or Mac.
Microsoft presented the particulars for CLI (which incorporates the center
class libraries, CTS, and CIL), and C++/CLI to both Ecma
International (ECMA) and International Organization for
Standardization (ISO), making them accessible as official models. This
makes it feasible for outsiders to make perfect executions of the system
and its dialects on different stages.
Security
.NET Framework has its own security mechanism with two general
features: Code Access Security (CAS), and identity-based security. Code
Access Security (CAS) is based on evidence that is associated with a
specific assembly. Using Code Access Security, you set policies and
permissions on assemblies according to their publisher or where they
were loaded from, for example. The user identity of the hosting process is
irrelevant in the permission granting logic. Compared with Code Access
Security, identity-based security represents a classic approach with
which most developers are confident.
Language independence
The .NET Framework is language independent. It is possible to use .Net
from many programming languages because they have all agreed on some
standards. This means that, as a programmer, you can develop in one of
the many languages that target the .NET Framework, such as C#,
C++/CLI, Eiffel, F#, IronPython, IronRuby, PowerBuilder, Visual Basic,
Visual COBOL, and Windows PowerShell. The .NET Framework
presents a Common Type System (CTS) that characterizes every
conceivable data sorts and programming builds bolstered by Common
Language Runtime and how they might communicate with each other
fitting in with CLI determination. 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
Type-Safety is a very important feature of .NET Framework and it is
enforced by the CLR and the Language Compiler - in accordance to the
CTS (Common Type System) directives of the .NET Framework. Type-
safe code cannot perform an operation on an object that is invalid for that
object. This prevents ill-defined casts, wrong method invocations, and
memory size issues when accessing an object. For example, if you have
declared a variable as an integer, it cannot be assigned any value which is
not an integer (by implicit conversion, or explicit conversion).
Memory management
Automatic memory management is one of the services that the Common
Language Runtime provides during Managed Execution. Using
the Garbage Collection (GC) Pattern method to limit or eliminate
memory leaks in your .Net applications and provide a more efficient
developer experience. The Common Language Runtime's garbage
collector handled the allocation and release of memory for an application,
which eliminates common problems such as missing to free an object and
causing a memory leak , or attempting to access memory for an object
that has already been released. More on... Garbage Collection
How to Microsoft .Net Framework
Microsoft .Net Languages Source Code are compiled into Microsoft
Intermediate Language (MSIL) . MSIL we can call it as Intermediate
Language (IL) or Common Intermediate Language (CIL). Microsoft
Intermediate Language (MSIL) is a CPU independent set of instructions
that can be converted to the native code. Metadata also created in the
course of compile time with Microsoft Intermediate Language (MSIL)
and stored it with the compiled code . Metadata is completely self-
describing . Metadata is stored in a file called Manifest, and it contains
information about the members, types, references and all the other data
that the Common Language Runtime (CLR) needs for execution.
The Common Language Runtime (CLR) uses metadata to locate and load
classes, generate native code, provide security, and execute Managed
Code. Both Microsoft Intermediate Language (MSIL) and Metadata
assembled together is known as Portable Executable (PE) file. Portable
Executable (PE) is supposed to be portable across all 32-bit operating
systems by Microsoft .Net Framework.
During the runtime the Common Language Runtime (CLR)'s Just In Time
(JIT) compiler converts the Microsoft Intermediate Language (MSIL)
code into native code to the Operating System. The native code is
Operating System independent and this code is known as Managed Code
, that is, the language's functionality is managed by the .NET Framework
. The Common Language Runtime (CLR) provides various Just In Time
(JIT) compilers, and each works on a different architecture depends on
Operating Systems, that means the same Microsoft Intermediate
Language (MSIL) can be executed on different Operating Systems. From
the following section you can see how Common Language Runtime
(CLR) functions .
Can I run .Net Framework on Linux ?
Microsoft .Net framework is proprietary Windows software and requires
the Windows API to run. It will not run natively in Linux. But there is an
open source implementation of .NET Framework called MONO which
has almost the same functionality of the MS .NET.
Mono Project
Mono is a free and open source project led by Xamarin. It is an open
source implementation of Microsoft's .NET Framework based on the
ECMA standards for C# and the Common Language Runtime. More
about : MONO
Common Language Specification - CLS
Common Language Specification (CLS) is a set of basic language features
that .Net Languages needed to develop Applications and Services , which
are compatible with the .Net Framework. When there is a situation to
communicate Objects written in different .Net Complaint languages ,
those objects must expose the features that are common to all the
languages . Common Language Specification (CLS) ensures complete
interoperability among applications, regardless of the language used to
create the application.
Common Language Specification (CLS) defines a subset of Common
Type System (CTS) . Common Type System (CTS) describes a set of
types that can use different .Net languages have in common , which ensure
that objects written in different languages can interact with each other.
Most of the members defined by types in the .NET Framework Class
Library (FCL) are Common Language Specification (CLS) compliant
Types. Moreover Common Language Specification (CLS) standardized
by ECMA .
Common Type System - CTS
Common Type System (CTS) describes a set of types that can be used in
different .Net languages in common . That is , the Common Type System
(CTS) ensure that objects written in different .Net languages can interact
with each other. For Communicating between programs written in any
.NET complaint language, the types have to be compatible on the basic
level .
These types can be Value Types or Reference Types . The Value Types
are passed by values and stored in the stack. The Reference Types are
passed by references and stored in the heap. Common Type System (CTS)
provides base set of Data Types which is responsible for cross language
integration. The Common Language Runtime (CLR) can load and
execute the source code written in any .Net language, only if the type is
described in the Common Type System (CTS) .Most of the members
defined by types in the .NET Framework Class Library (FCL)
are Common Language Specification (CLS) compliant Types.
Microsoft Intermediate Language - MSIL
MSIL stands for Microsoft Intermediate Language. We can call it as
Intermediate Language (IL) or Common Intermediate Language (CIL).
During the compile time , the compiler convert the source code into
Microsoft Intermediate Language (MSIL) .Microsoft Intermediate
Language (MSIL) is a CPU-independent set of instructions that can be
efficiently converted to the native code. During the runtime the Common
Language Runtime (CLR)'s Just In Time (JIT) compiler converts the
Microsoft Intermediate Language (MSIL) code into native code to the
Operating System.
When a compiler produces Microsoft Intermediate Language (MSIL), it
also produces Metadata. The Microsoft Intermediate Language (MSIL)
and Metadata are contained in a portable executable (PE) file . Microsoft
Intermediate Language (MSIL) includes instructions for loading, storing,
initializing, and calling methods on objects, as well as instructions for
arithmetic and logical operations, control flow, direct memory access,
exception handling, and other operations
Portable Executable (PE) File Format
The Portable Executable (PE) format is a file format for executables,
object code, and DLLs, used in 32-bit and 64-bit versions of Windows
operating systems.
The PE file format was defined to provide the best way for the Windows
Operating System to execute code and also to store the essential data
which is needed to run a program. Portable Executable File Format is
derived from the Microsoft Common Object File Format (COFF).
Microsoft .Net Namespaces
Namespaces are the way to organize .NET Framework Class Library into
a logical grouping according to their functionality, usability as well as
category they should belong to, or we can say Namespaces are logical
grouping of types for the purpose of identification.
The .NET Framework Class Library (FCL ) is a large collection of
thousands of Classes. These Classes are organized in a hierarchical tree.
The System Namespaces is the root for types in the .NET Framework. We
can uniquely identify any Class in the .NET Framework Class Library
(FCL ) by using the full Namespaces of the class .In .Net languages every
program is created with a default Namespaces . Programmers can also
create their own Namespaces in .Net languages.
.Net Application Domain
An application domain is a virtual process and is used to isolate
applications from one another. Each application domain has their own
virtual address space which scopes the resources for the application
domain using that address space.
Each application running within its main process boundaries and its
application domain boundaries. All objects created within the same
application scope are created within the same application domain.
Multiple application domains can exist in a single operating system
process. An application running inside one application domain cannot
directly access the code running inside another application domain.
[Link] is the main class you can use to deal with application
domains.
How to Common Language Runtime - CLR
The Common Language Runtime (CLR) is a an Execution Environment .
Common Language Runtime (CLR)'s main tasks are to convert the .NET
Managed Code to native code , manage running code like a Virtual
Machine and also controls the interaction with the Operating System.
Common Language Runtime (CLR) manages Thread executions,
Memory Management that is allocation of Objects and Buffers , Garbage
Collection (GC) - Clean up the unused Objects and buffers , Exception
Handling, Common Type System (CTS) that is all .NET language that
conforms to the Common Language Specification (CLS) have the same
primitive Data Types, Code safety verifications - code can be verified to
ensure type safety, Language integration that is Common Language
Runtime (CLR) follow a set of specification called Common Language
Specification (CLS) , this will ensure the interoperability between
languages, Integrated security and other system services.
Net Framework Class Library (FCL)
The .Net Framework class library (FCL) provides the core functionality
of .Net Framework architecture . The .Net Framework Class Library
(FCL) includes a huge collection of reusable classes , interfaces, and value
types that expedite and optimize the development process and provide
access to system functionality.
The .Net Framework class library (FCL) organized in a hierarchical tree
structure and it is divided into Namespaces. Namespaces is a logical
grouping of types for the purpose of identification. Framework class
library (FCL) provides the consistent base types that are used across all
.NET enabled languages. The Classes are accessed by namespaces, which
reside within Assemblies. The System Namespace is the root for types in
the .NET Framework. The .Net Framework class library (FCL) classes are
managed classes that provide access to System Services . The .Net
Framework class library (FCL) classes are object oriented and easy to use
in program developments. Moreover, third-party components can
integrate with the classes in the .NET Framework.