You are on page 1of 25

What is .NET Framework?

Complete
Architecture Tutorial
What is Microsoft .Net Framework?
The .Net framework is a software development platform developed by
Microsoft. The framework was meant to create applications, which would run
on the Windows Platform. The first version of the .Net framework was
released in the year 2002.

The version was called .Net framework 1.0. The .Net framework has come a
long way since then, and the current version is 4.7.1.

The .Net framework can be used to create both - Form-based and Web-
based applications. Web services can also be developed using the .Net
framework.

The framework also supports various programming languages such as Visual


Basic and C#. So developers can choose and select the language to develop
the required application. In this chapter, you will learn some basics of the .Net
framework.

In this tutorial, you will learn-

 .Net Framework Architecture


 .NET Components
 .Net Framework Design Principle
.Net Framework Architecture
The basic architecture of the .Net framework is as shown below.

.net framework architecture diagram

.NET Components
The architecture of the .Net framework is based on the following key
components;

1. Common Language Runtime


The "Common Language Infrastructure" or CLI is a platform on which the .Net
programs are executed.

The CLI has the following key features:

 Exception Handling - Exceptions are errors which occur when the


application is executed.

Examples of exceptions are:

o If an application tries to open a file on the local machine, but the


file is not present.
o If the application tries to fetch some records from a database, but
the connection to the database is not valid.
 Garbage Collection - Garbage collection is the process of removing
unwanted resources when they are no longer required.
Examples of garbage collection are

o A File handle which is no longer required. If the application has


finished all operations on a file, then the file handle may no longer
be required.
o The database connection is no longer required. If the application
has finished all operations on a database, then the database
connection may no longer be required.
 Working with Various programming languages –

As noted in an earlier section, a developer can develop an application in a


variety of .Net programming languages.

1. Language - The first level is the programming language itself, the most
common ones are VB.Net and C#.
2. Compiler – There is a compiler which will be separate for each
programming language. So underlying the VB.Net language, there will
be a separate VB.Net compiler. Similarly, for C#, you will have another
compiler.
3. Common Language Interpreter – This is the final layer in .Net which
would be used to run a .net program developed in any programming
language. So the subsequent compiler will send the program to the CLI
layer to run the .Net application.

2. Class Library
The .NET Framework includes a set of standard class libraries. A class library
is a collection of methods and functions that can be used for the core purpose.
For example, there is a class library with methods to handle all file-level
operations. So there is a method which can be used to read the text from a
file. Similarly, there is a method to write text to a file.

Most of the methods are split into either the System.* or Microsoft.*
namespaces. (The asterisk * just means a reference to all of the methods that
fall under the System or Microsoft namespace)

A namespace is a logical separation of methods. We will learn these


namespaces more in detail in the subsequent chapters.

3. Languages
The types of applications that can be built in the .Net framework is classified
broadly into the following categories.

 WinForms – This is used for developing Forms-based applications,


which would run on an end user machine. Notepad is an example of a
client-based application.
 ASP.Net – This is used for developing web-based applications, which
are made to run on any browser such as Internet Explorer, Chrome or
Firefox.
o The Web application would be processed on a server, which
would have Internet Information Services Installed.
o Internet Information Services or IIS is a Microsoft component
which is used to execute anAsp.Net application.
o The result of the execution is then sent to the client machines,
and the output is shown in the browser.
 ADO.Net – This technology is used to develop applications to interact
with Databases such as Oracle or Microsoft SQL Server.

Microsoft always ensures that .Net frameworks are in compliance with all the
supported Windows operating systems.

.Net Framework Design Principle


The following design principles of the .Net framework is what makes it very
relevant to create .Net based applications.

1. Interoperability - The .Net framework provides a lot of backward


support. Suppose if you had an application built on an older version of
the .Net framework, say 2.0. And if you tried to run the same application
on a machine which had the higher version of the .Net framework, say
3.5. The application would still work. This is because with every release,
Microsoft ensures that older framework versions gel well with the latest
version.
2. Portability- Applications built on the .Net framework can be made to
work on any Windows platform. And now in recent times, Microsoft is
also envisioning to make Microsoft products work on other platforms,
such as iOS and Linux.
3. Security - The .NET Framework has a good security mechanism. The
inbuilt security mechanism helps in both validation and verification of
applications. Every application can explicitly define their security
mechanism. Each security mechanism is used to grant the user access
to the code or to the running program.
4. Memory management - The Common Language runtime does all the
work or memory management. The .Net framework has all the capability
to see those resources, which are not used by a running program. It
would then release those resources accordingly. This is done via a
program called the "Garbage Collector" which runs as part of the .Net
framework.

The garbage collector runs at regular intervals and keeps on checking


which system resources are not utilized, and frees them accordingly.

5. Simplified deployment - The .Net framework also have tools, which can
be used to package applications built on the .Net framework. These
packages can then be distributed to client machines. The packages
would then automatically install the application.

Summary

 .Net is a programming language developed by Microsoft. It was


designed to build applications which could run on the Windows platform.
 The .Net programming language can be used to develop Forms based
applications, Web based applications, and Web services.
 Developers can choose from a variety of programming languages
available on the .Net platform. The most common ones are VB.Net and
C#.
.NET Framework

.NET is a framework which is used to develop software applications. It is designed and


developed by Microsoft and first beta version released on 2000.

It is used to build applications for web, Windows, phone and provides broad range of
functionalities and support for industry standards.

This framework contains large number of class libraries known as Framework Class Library
(FCL).

The software programs written in .NET are execute in execution environment that is called
CLR (Common Language Runtime).

These both are core and essential parts of the .NET Framework.

This Framework provides various services like: memory management, networking, security
and memory safety. It also supports numerous programing languages like: C#, F#, VB etc.

Following is the .NET framework Stack that shows the modules and components of the
Framework.
CLR (Common Language Runtime)
It is a program execution engine that loads and execute program. It acts as a interface
between framework and operating system.

FCL (Framework Class Library)


It is a standard library that is collection of thousands of classes and used to build
application. The BCL (Base Class Library) is the core of the FCL and provides fundamental
functionalities.

WinForms
Windows Forms is a smart client technology for the .NET Framework, a set of managed
libraries that simplify common application tasks such as reading and writing to the file
system.

ASP .NET
ASP .NET is a web framework designed and developed by Microsoft. It is used to develop
websites, web applications and web services. It provides fantastic integration of HTML, CSS
and JavaScript. It was first released in January 2002.

ADO .NET
ADO .NET is a module of .Net Framework which is used to establish connection between
application and data sources. Data sources can be such as SQL Server and XML. ADO .NET
consists of classes that can be used to connect, retrieve, insert and delete data.

WPF (Windows Presentation Foundation)


Windows Presentation Foundation (WPF) is a graphical subsystem by Microsoft for rendering
user interfaces in Windows-based applications. WPF, previously known as "Avalon", was
initially released as part of .NET Framework 3.0 in 2006. WPF uses DirectX.

WCF (Windows Communication Foundation)


It is a framework for building service-oriented applications. Using WCF, you can send data
as asynchronous messages from one service endpoint to another.

WF (WorkFlow Foundation)
Windows Workflow Foundation (WF) is a Microsoft technology that provides an API, an in-
process workflow engine, and a rehostable designer to implement long-running processes as
workflows within .NET applications.

LINQ (Language Integrated Query)


It is a query language, introduced in .NET 3.5 framework. It is used to make query for data
sources with C# or Visual Basics programming languages.

Entity Framework
It is an ORM based open source framework that is used to work with a database using .NET
objects. It eliminates lots of developer effort to handle the database. It is Microsoft's
recommended technology to deal with database.

Parallel LINQ
Parallel LINQ or PLINQ is a parallel implementation of LINQ to objects. It combines the
simplicity and readability of LINQ and provide power of parallel programing.

It can improve and provide fast speed to execute the LINQ query by using all available
computer capabilities.

Apart from above features and libraries .NET include other APIs and Model to improve and
enhance the .NET framework.

In 2015, Task parallel and Task parallel libraries are added and in .NET 4.5, task based
asynchronous model was added.

Standard Generalized Markup


Language (SGML)
Definition - What does Standard Generalized Markup Language
(SGML) mean?
Standard generalized markup language (SGML) is a text markup language that serves
as a superset of widely used markup languages like HTML (hypertext markup language)
and XML (extensible markup language).

SGML is used for marking up documents and has the advantage of not being
dependent on a specific application. It is derived from GML (generalized markup
language), which allowed users to work on standardized formatting styles for electronic
documents.
FREE WEBINAR - March 12, 2019 11:00am EST | Managing Multiple Database Roles: How Many
Hats Do You Wear? REGISTER TODAY

Techopedia explains Standard Generalized Markup Language


(SGML)
Standard generalized markup language features the following characteristics:

 Descriptive Markup
 Document Types

Descriptive markup involves the use of markup code that identify how various portions
of a document should be interpreted. For example, the code may identify one portion as
a paragraph, another as a footnote and still another as a list or an item in a list.

Any software capable of processing the marked-up document will then do so using its
own kind of rendering. For example, one application might gather portions identified as
footnotes and print them out at the end of each page. Another might print footnotes at
the end of each chapter. Still another might not print out the footnotes at all.

Another important characteristic of standard generalized markup language is its use of


document types, and subsequently it use of document type definition (DTD). A particular
document type is expected to have specific parts and a specific structure. For example,
when there is a DTD for a report, the portions and structure of the document should
follow what is defined in the DTD for it to be considered a report. One major benefit is
that documents with the same type can be processed uniformly by all software capable
of processing them.

XML stands for Extensible Markup Language. It is a text-based markup


language derived from Standard Generalized Markup Language (SGML).

XML tags identify the data and are used to store and organize the data,
rather than specifying how to display it like HTML tags, which are used to
display the data. XML is not going to replace HTML in the near future, but it
introduces new possibilities by adopting many successful features of HTML.

There are three important characteristics of XML that make it useful in a


variety of systems and solutions −
 XML is extensible − XML allows you to create your own self-descriptive tags,
or language, that suits your application.

 XML carries the data, does not present it − XML allows you to store the data
irrespective of how it will be presented.

 XML is a public standard − XML was developed by an organization called the


World Wide Web Consortium (W3C) and is available as an open standard.

XML Usage
A short list of XML usage says it all −

 XML can work behind the scene to simplify the creation of HTML documents for
large web sites.

 XML can be used to exchange the information between organizations and


systems.

 XML can be used for offloading and reloading of databases.

 XML can be used to store and arrange the data, which can customize your data
handling needs.

 XML can easily be merged with style sheets to create almost any desired output.

 Virtually, any type of data can be expressed as an XML document.

What is Markup?
XML is a markup language that defines set of rules for encoding documents
in a format that is both human-readable and machine-readable. So what
exactly is a markup language? Markup is information added to a document
that enhances its meaning in certain ways, in that it identifies the parts and
how they relate to each other. More specifically, a markup language is a set
of symbols that can be placed in the text of a document to demarcate and
label the parts of that document.

Following example shows how XML markup looks, when embedded in a


piece of text −

<message>

<text>Hello, world!</text>
</message>

This snippet includes the markup symbols, or the tags such as


<message>...</message> and <text>... </text>. The tags <message>
and </message> mark the start and the end of the XML code fragment.
The tags <text> and </text> surround the text Hello, world!.

Is XML a Programming Language?


A programming language consists of grammar rules and its own vocabulary
which is used to create computer programs. These programs instruct the
computer to perform specific tasks. XML does not qualify to be a
programming language as it does not perform any computation or
algorithms. It is usually stored in a simple text file and is processed by
special software that is capable of interpreting XML.

What is XML?
 XML stands for eXtensible Markup Language
 XML is a markup language much like HTML
 XML was designed to store and transport data
 XML was designed to be self-descriptive
 XML is a W3C Recommendation

XML Does Not DO Anything


Maybe it is a little hard to understand, but XML does not DO anything.

This note is a note to Tove from Jani, stored as XML:

<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>

The XML above is quite self-descriptive:


 It has sender information.
 It has receiver information
 It has a heading
 It has a message body.

But still, the XML above does not DO anything. XML is just information wrapped
in tags.

Someone must write a piece of software to send, receive, store, or display it:

Note
To: Tove

From: Jani

Reminder
Don't forget me this weekend!

The Difference Between XML and HTML


XML and HTML were designed with different goals:

 XML was designed to carry data - with focus on what data is


 HTML was designed to display data - with focus on how data looks
 XML tags are not predefined like HTML tags are

XML Does Not Use Predefined Tags


The XML language has no predefined tags.

The tags in the example above (like <to> and <from>) are not defined in any
XML standard. These tags are "invented" by the author of the XML document.
HTML works with predefined tags like <p>, <h1>, <table>, etc.

With XML, the author must define both the tags and the document structure.

XML is Extensible
Most XML applications will work as expected even if new data is added (or
removed).

Imagine an application designed to display the original version of note.xml


(<to> <from> <heading> <body>).

Then imagine a newer version of note.xml with added <date> and <hour>
elements, and a removed <heading>.

The way XML is constructed, older version of the application can still work:

<note>
<date>2015-09-01</date>
<hour>08:30</hour>
<to>Tove</to>
<from>Jani</from>
<body>Don't forget me this weekend!</body>
</note>

Old Version

Note
To: Tove

From: Jani

Reminder
Don't forget me this weekend!

New Version
Note
To: Tove

From: Jani

Date: 2015-09-01 08:30

Don't forget me this weekend!

XML Simplifies Things


 It simplifies data sharing
 It simplifies data transport
 It simplifies platform changes
 It simplifies data availability

Many computer systems contain data in incompatible formats. Exchanging data


between incompatible systems (or upgraded systems) is a time-consuming task
for web developers. Large amounts of data must be converted, and
incompatible data is often lost.

XML stores data in plain text format. This provides a software- and hardware-
independent way of storing, transporting, and sharing data.

XML also makes it easier to expand or upgrade to new operating systems, new
applications, or new browsers, without losing data.

With XML, data can be available to all kinds of "reading machines" like people,
computers, voice machines, news feeds, etc.

XML - CDATA Sections


Advertisements

Previous Page
Next Page
In this chapter, we will discuss XML CDATA section. The term CDATA
means, Character Data. CDATA is defined as blocks of text that are not
parsed by the parser, but are otherwise recognized as markup.

The predefined entities such as &lt;, &gt;, and &amp; require typing and
are generally difficult to read in the markup. In such cases, CDATA section
can be used. By using CDATA section, you are commanding the parser that
the particular section of the document contains no markup and should be
treated as regular text.

Syntax
Following is the syntax for CDATA section −

<![CDATA[

characters with markup

]]>

The above syntax is composed of three sections −

 CDATA Start section − CDATA begins with the nine-character


delimiter <![CDATA[

 CDATA End section − CDATA section ends with ]]> delimiter.

 CData section − Characters between these two enclosures are interpreted as


characters, and not as markup. This section may contain markup characters (<,
>, and &), but they are ignored by the XML processor.

Example
The following markup code shows an example of CDATA. Here, each
character written inside the CDATA section is ignored by the parser.

<script>

<![CDATA[

<message> Welcome to TutorialsPoint </message>

]] >

</script >
In the above syntax, everything between <message> and </message> is
treated as character data and not as markup.

CDATA Rules
The given rules are required to be followed for XML CDATA −

 CDATA cannot contain the string "]]>" anywhere in the XML document.

 Nesting is not allowed in CDATA section.

CDATA vs PCDATA

CDATA
CDATA: (Unparsed Character data): CDATA contains the text which is not parsed further in
an XML document. Tags inside the CDATA text are not treated as markup and entities will
not be expanded.

Let's take an example for CDATA:

1. <?xml version="1.0"?>
2. <!DOCTYPE employee SYSTEM "employee.dtd">
3. <employee>
4. <![CDATA[
5. <firstname>vimal</firstname>
6. <lastname>jaiswal</lastname>
7. <email>vimal@javatpoint.com</email>
8. ]]>
9. </employee>
Test it Now

In the above CDATA example, CDATA is used just after the element employee to make the
data/text unparsed, so it will give the value of employee:

<firstname>vimal</firstname><lastname>jaiswal</lastname><email>vimal@javatpoi
nt.com</email>

PCDATA
PCDATA: (Parsed Character Data): XML parsers are used to parse all the text in an XML
document. PCDATA stands for Parsed Character data. PCDATA is the text that will be parsed
by a parser. Tags inside the PCDATA will be treated as markup and entities will be
expanded.

In other words you can say that a parsed character data means the XML parser examine the
data and ensure that it doesn't content entity if it contains that will be replaced.

Let's take an example:

1. <?xml version="1.0"?>
2. <!DOCTYPE employee SYSTEM "employee.dtd">
3. <employee>
4. <firstname>vimal</firstname>
5. <lastname>jaiswal</lastname>
6. <email>vimal@javatpoint.com</email>
7. </employee>
Test it Now

In the above example, the employee element contains 3 more elements 'firstname',
'lastname', and 'email', so it parses further to get the data/text of firstname, lastname and
email to give the value of employee as:

vimal jaiswal vimal@javatpoint.com

XML - Validation
Advertisements

Previous Page
Next Page

Validation is a process by which an XML document is validated. An XML


document is said to be valid if its contents match with the elements,
attributes and associated document type declaration(DTD), and if the
document complies with the constraints expressed in it. Validation is dealt
in two ways by the XML parser. They are −
 Well-formed XML document

 Valid XML document

Well-formed XML Document


An XML document is said to be well-formed if it adheres to the following
rules −

 Non DTD XML files must use the predefined character entities
for amp(&), apos(single quote), gt(>), lt(<), quot(double quote).

 It must follow the ordering of the tag. i.e., the inner tag must be closed before
closing the outer tag.

 Each of its opening tags must have a closing tag or it must be a self ending
tag.(<title>....</title> or <title/>).

 It must have only one attribute in a start tag, which needs to be quoted.

 amp(&), apos(single quote), gt(>), lt(<), quot(double quote)entities


other than these must be declared.

Example
Following is an example of a well-formed XML document −

<?xml version = "1.0" encoding = "UTF-8" standalone = "yes" ?>

<!DOCTYPE address

<!ELEMENT address (name,company,phone)>

<!ELEMENT name (#PCDATA)>

<!ELEMENT company (#PCDATA)>

<!ELEMENT phone (#PCDATA)>

]>

<address>

<name>Tanmay Patil</name>

<company>TutorialsPoint</company>
<phone>(011) 123-4567</phone>

</address>

The above example is said to be well-formed as −

 It defines the type of document. Here, the document type is elementtype.

 It includes a root element named as address.

 Each of the child elements among name, company and phone is enclosed in its
self explanatory tag.

 Order of the tags is maintained.

Valid XML Document


If an XML document is well-formed and has an associated Document Type
Declaration (DTD), then it is said to be a valid XML document. We will study
more about DTD in the chapter XML - DTDs.

XML - DTDs
Advertisements

Previous Page
Next Page

The XML Document Type Declaration, commonly known as DTD, is a way to


describe XML language precisely. DTDs check vocabulary and validity of the
structure of XML documents against grammatical rules of appropriate XML
language.

An XML DTD can be either specified inside the document, or it can be kept
in a separate document and then liked separately.

Syntax
Basic syntax of a DTD is as follows −

<!DOCTYPE element DTD identifier


[

declaration1

declaration2

........

]>

In the above syntax,

 The DTD starts with <!DOCTYPE delimiter.

 An element tells the parser to parse the document from the specified root
element.

 DTD identifier is an identifier for the document type definition, which may be
the path to a file on the system or URL to a file on the internet. If the DTD is
pointing to external path, it is called External Subset.

 The square brackets [ ] enclose an optional list of entity declarations


called Internal Subset.

Internal DTD
A DTD is referred to as an internal DTD if elements are declared within the
XML files. To refer it as internal DTD, standalone attribute in XML
declaration must be set to yes. This means, the declaration works
independent of an external source.

Syntax
Following is the syntax of internal DTD −
<!DOCTYPE root-element [element-declarations]>

where root-element is the name of root element and element-


declarations is where you declare the elements.

Example
Following is a simple example of internal DTD −

<?xml version = "1.0" encoding = "UTF-8" standalone = "yes" ?>

<!DOCTYPE address [
<!ELEMENT address (name,company,phone)>

<!ELEMENT name (#PCDATA)>

<!ELEMENT company (#PCDATA)>

<!ELEMENT phone (#PCDATA)>

]>

<address>

<name>Tanmay Patil</name>

<company>TutorialsPoint</company>

<phone>(011) 123-4567</phone>

</address>

Let us go through the above code −

Start Declaration − Begin the XML declaration with the following


statement.
<?xml version = "1.0" encoding = "UTF-8" standalone = "yes" ?>

DTD − Immediately after the XML header, the document type


declarationfollows, commonly referred to as the DOCTYPE −
<!DOCTYPE address [

The DOCTYPE declaration has an exclamation mark (!) at the start of the
element name. The DOCTYPE informs the parser that a DTD is associated
with this XML document.

DTD Body − The DOCTYPE declaration is followed by body of the DTD,


where you declare elements, attributes, entities, and notations.

<!ELEMENT address (name,company,phone)>

<!ELEMENT name (#PCDATA)>

<!ELEMENT company (#PCDATA)>

<!ELEMENT phone_no (#PCDATA)>


Several elements are declared here that make up the vocabulary of the
<name> document. <!ELEMENT name (#PCDATA)> defines the
element nameto be of type "#PCDATA". Here #PCDATA means parse-able
text data.

End Declaration − Finally, the declaration section of the DTD is closed


using a closing bracket and a closing angle bracket (]>). This effectively
ends the definition, and thereafter, the XML document follows immediately.

Rules
 The document type declaration must appear at the start of the document
(preceded only by the XML header) − it is not permitted anywhere else within
the document.

 Similar to the DOCTYPE declaration, the element declarations must start with an
exclamation mark.

 The Name in the document type declaration must match the element type of the
root element.

External DTD
In external DTD elements are declared outside the XML file. They are
accessed by specifying the system attributes which may be either the
legal .dtd file or a valid URL. To refer it as external
DTD, standalone attribute in the XML declaration must be set as no. This
means, declaration includes information from the external source.

Syntax
Following is the syntax for external DTD −
<!DOCTYPE root-element SYSTEM "file-name">

where file-name is the file with .dtd extension.

Example
The following example shows external DTD usage −

<?xml version = "1.0" encoding = "UTF-8" standalone = "no" ?>

<!DOCTYPE address SYSTEM "address.dtd">

<address>
<name>Tanmay Patil</name>

<company>TutorialsPoint</company>

<phone>(011) 123-4567</phone>

</address>

The content of the DTD file address.dtd is as shown −

<!ELEMENT address (name,company,phone)>

<!ELEMENT name (#PCDATA)>

<!ELEMENT company (#PCDATA)>

<!ELEMENT phone (#PCDATA)>

Types
You can refer to an external DTD by using either system
identifiers or public identifiers.

System Identifiers
A system identifier enables you to specify the location of an external file
containing DTD declarations. Syntax is as follows −
<!DOCTYPE name SYSTEM "address.dtd" [...]>

As you can see, it contains keyword SYSTEM and a URI reference pointing
to the location of the document.

Public Identifiers
Public identifiers provide a mechanism to locate DTD resources and is
written as follows −
<!DOCTYPE name PUBLIC "-//Beginning XML//DTD Address Example//EN">

As you can see, it begins with keyword PUBLIC, followed by a specialized


identifier. Public identifiers are used to identify an entry in a catalog. Public
identifiers can follow any format, however, a commonly used format is
called Formal Public Identifiers, or FPIs.
XML - Namespaces
Advertisements

Previous Page
Next Page

A Namespace is a set of unique names. Namespace is a mechanisms by


which element and attribute name can be assigned to a group. The
Namespace is identified by URI(Uniform Resource Identifiers).

Namespace Declaration
A Namespace is declared using reserved attributes. Such an attribute name
must either be xmlns or begin with xmlns: shown as below −
<element xmlns:name = "URL">

Syntax
 The Namespace starts with the keyword xmlns.

 The word name is the Namespace prefix.

 The URL is the Namespace identifier.

Example
Namespace affects only a limited area in the document. An element
containing the declaration and all of its descendants are in the scope of the
Namespace. Following is a simple example of XML Namespace −

<?xml version = "1.0" encoding = "UTF-8"?>

<cont:contact xmlns:cont = "www.tutorialspoint.com/profile">

<cont:name>Tanmay Patil</cont:name>

<cont:company>TutorialsPoint</cont:company>

<cont:phone>(011) 123-4567</cont:phone>

</cont:contact>
Here, the Namespace prefix is cont, and the Namespace identifier (URI)
as www.tutorialspoint.com/profile. This means, the element names and
attribute names with the cont prefix (including the contact element), all
belong to the www.tutorialspoint.com/profile namespace.