1. History
.NET is the Microsoft Web services strategy to connect information, people, systems, and
devices through software.
Integrated across the Microsoft platform, .NET technology provides the ability to quickly
build, deploy, manage, and use connected, security-enhanced solutions with Web services.
.NET was originally called NGWS (Next Generation Windows Services).
Web services are self-describing software modules, semantically encapsulating discrete
functionality, wrapped in and accessible via standard Internet communication protocols such
as XML and SOAP.
.NET framework also includes versions for mobile and embedded devices.
1
2. Basics
.NET is a programming framework created by Microsoft that developers can use to create
applications more easily. Framework provides libraries commonly used by the developers.
.NET Base Class Libraries (BCL) serves that purpose.
.NET provides language interoperability across several programming languages. Programs
written for .NET framework execute in a software environment called Common Language
Runtime (CLR).
CLR is the foundation of .NET framework which provides services like type safety, memory
management, garbage collection, and exception handling.
CLR manages execution of code. Code that is managed by CLR is called managed code.
Unmanaged code doesn’t get managed by CLR. CLR’s interoperability helps to interact
between managed and unmanaged code.
Common Language Specification(CLS) and Common Type System (CTS) as part of CLR. CTS is
responsible for interpreting the data types into common format. Ex: number of bytes for an
integer. CLS provides ability of code to interact with code that is written using a different
programming language.
2
4. Lifecycle
Microsoft started creating .NET framework in 1990s. By late2000 the first version on .NET 1.0
was released.
Since then Microsoft has released .NET 1.1, 2.0, 3.0, 3.5, 4.0, & 4.5 versions of the framework.
Microsoft added additional features and functionality in every release to make development
easier using Visual Studio IDE.
4
5.
6. Content - .Net
Features of .Net
Rich Functionality out of the box
Easy development of web applications
OOPs Support
Multi-Language Support
Multi-Device Support
Automatic memory management
Compatibility with COM and COM+
No more DLL Hell
Strong XML support
Ease of deployment and configuration
Security
6
8. Content - .Net
Just-In-Time Complilation (JIT)
The MSIL is the language that all of the .NET languages compile down to. After they are
in this intermediate language, a process called Just-In-Time (JIT) compilation occurs
when resources are used from your application at runtime
Metadata - Metadata describes every type and member defined in your code in a
Multilanguage form. Metadata stores the following information:
• Description of the assembly
• Identity (name, version, culture, public key).
• The types that are exported.
• Other assemblies that this assembly depends on.
• Security permissions needed to run
Assembly - Assemblies are the building blocks of .NET Framework applications; they form the
fundamental unit of deployment, version control, reuse, activation scoping, and security
permissions
8
9. Content - .Net
Managed Code / Methods - Machine instructions in MSIL format and located in Assemblies
will be executed by the CLR, will have the following intrinsic advantages, Memory
management to prevent memory leaks in the program code,
Thread execution,
Code safety verification,
Compilation,
Unmanaged Code / Methods - Unmanaged codes are the instructions, which are targeted for
specific platforms. Unmanaged code will exist in any of the format, A code instructions in
managed C++ with “#pragma unmanaged”
COM/COM+ Components
Win32 Dlls/System Dlls
As these codes are in native format of OS, these instructions will be executed faster
compared with JIT compilation and execution of Managed code
9
10. Content - What is DLL HELL in .NET
10
1. I have 2 applications, A1 and A2 installed on my computer.
2. Both of these applications use shared assembly shared.dll
3. Now, I have a latest version of Application - A2 available on the internet.
4. I download the latest version of A2 and install it on my machine.
5. This new installation has over written Shared.dll, which is also used by Application - A1.
6. Application - A2 works fine, but A1 fails to work, because the newly installed Shared.dll is not backward compatible.
So, DLL HELL is a problem where one application will install a new version of the shared component that is not backward
compatible with the version already on the machine, causing all the other existing applications that rely on the shared
component to break. With .NET versioning we donot have DLL HELL problem any more.
11. Content - How is the DLL HELL problem solved in .NET
11
In dot net all the shared assemblies are usually in the GAC. GAC stands for Global Assembly Cache. The path
for GAC is C:[OperatingSystemDirectory]assembly. For example on my computer the path
is C:WINDOWSassembly. The image below shows the shared assemblies in the GAC.
Only strong named assemblies can be copied into GAC. Strong named assemblies in .NET has 4 pieces in its
name as listed below.
1. Simple Textual Name
2. Version Number
3. Culture
4. Public Key Token
All these four pieces put together, is called as the fully qualified name of the assembly. In the GAC image
above Accessibility assembly has a version of 2.0.0.0.
35. • The variables we have been working with so far have only been able to hold one value at a
time
• Example:
int lotteryNumber1 = 1;
int lotteryNumber2 = 2;
int lotteryNumber3 = 3;
:
• An Array allows you to use just one identifying name that refers to lots of values
Why use Arrays?
36. 1. Declaration:
• int[] lotteryNumbers;
• float[] myFloatValues;
• string[] myStrings;
2. Size of array:
• lotteryNumbers = new int[4];
• myFloatValues = new float[10];
• myStrings = new string[5];
How to setup an Array
37. Declaration and setting the size in one line
• int[] lotteryNumbers = new int[4];
• float[] myFloatValues = new float[10];
• string[] myStrings = new string[5];
38. arrayName[position] = arrayValue;
int[] lotteryNumbers = new int[4];
lotteryNumbers[0] = 1; // first array
lotteryNumbers[1] = 2;
lotteryNumbers[2] = 3;
lotteryNumbers[3] = 4; // last (4th) array
Assigning values
39. int[] lotteryNumbers = new int[4];
lotteryNumbers[0] = 1;
lotteryNumbers[1] = 2;
lotteryNumbers[2] = 3;
lotteryNumbers[3] = 4;
First index is ZERO
40. int[] lotteryNumbers = new int[4];
lotteryNumbers[0] = 1;
lotteryNumbers[1] = 2;
lotteryNumbers[2] = 3;
lotteryNumbers[3] = 4;
Last index is (SIZE -1)
41. int[] lotteryNumbers = new int[4];
lotteryNumbers[0] = 1;
lotteryNumbers[1] = 2;
lotteryNumbers[2] = 3;
lotteryNumbers[3] = 4;
Total number of array =
SIZE
42. int[] lotteryNumbers = new int[4] {1, 2, 3, 4};
Declare, Set Array Size and Assign
Values in one line
Declare
45. To loop through the following array:
lotteryNumbers[0]
lotteryNumbers[1]
lotteryNumbers[2]
lotteryNumbers[3]
for (int i = 0; i != lotteryNumbers.Length; i++)
{
lotteryNumber[i] ….. // not complete
}
Arrays and Loops
46. for (int i = 0; i != lotteryNumbers.Length; i++)
{
lotteryNumber[i] ….. // not complete
}
starts from 0
The first index is ZERO
47. for (int i = 0; i != lotteryNumbers.Length; i++)
{
lotteryNumber[i] ….. // not complete
}
Length is equal to the SIZE of array
The last index should be (Length – 1)
48. for (int i = 0; i != lotteryNumbers.Length; i++)
{
lotteryNumber[i] ….. // not complete
}
i < lotteryNumers.Length
49. for (int i = 0; i != lotteryNumbers.Length; i++)
{
lotteryNumber[i] ….. // not complete
}
i <= lotteryNumers.Length -1
98. ADO.NET Agenda
• ADO versus ADO.NET
• ADO.NET Architecture
• Connection Object
• Command Object
• DataReader Object
• DataAdapter Object
• DataSet Object
• DataView Object
• Use ADO.NET to access data in an application
99. ADO versus ADO.NET
Feature ADO ADO.NET
Primary Aim Client/server coupled Disconnected collection of
data from data server
Form of data in
memory
Uses RECORDSET object
(contains one table)
Uses DATASET object
(contains one or more
DATATABLE objects)
Disconnected
access
Uses CONNECTION object
and RECORDSET object with
OLEDB
Uses DATASETCOMMAND
object with OLEDB
Disconnected
access across
multi-tiers
Uses COM to marshal
RECORDSET
Transfers DATASET object via
XML. No data conversions
required
100. ADO versus ADO.NET (continued)
Feature ADO ADO.NET
XML
capabilities
XML aware XML is the native transfer
medium for the objects
Firewalls Firewalls block system-level
COM marshalling
XML flows through the firewall
via HTTP
Code Coupled to the language
used, various implementation
Managed code library – Uses
Common Language Runtime,
therefore, language agnostic
101. Agenda
• ADO versus ADO.NET
• ADO.NET Architecture
• Connection Object
• Command Object
• DataReader Object
• DataAdapter Object
• DataSet Object
• DataView Object
• Use ADO.NET to access data in an application
103. ADO.NET Namespaces
System.data Core namespace, defines types that
represent data
System.Data.Common Types shared between managed providers
System.Data.OleDb Types that allow connection to OLE DB
compliant data sources
System.Data.SqlClient Types that are optimized to connect to
Microsoft® SQL Server
System.Data.SqlTypes Native data types in Microsoft® SQL
Server
104. Importing the ADO.NET Namespaces
Needed to build a data access application
• For OLE DB:
Imports System.Data
Imports System.Data.OleDB
• For SQL Server:
Imports System.Data
Imports System.Data.SQLClient
105. Agenda
• ADO versus ADO.NET
• ADO.NET Architecture
• Connection Object
• Command Object
• DataReader Object
• DataAdapter Object
• DataSet Object
• DataView Object
• Use ADO.NET to access data in an application
106. Connection object
• Connects to databases.
• Two provider-specific classes
o SqlConnection
o OleDbConnection.
• Connections can be opened in two ways:
o Explicitly by calling the Open method on the
connection
o Implicitly when using a DataAdapter.
• Connections handle transactions
107. Agenda
• ADO versus ADO.NET
• ADO.NET Architecture
• Connection Object
• Command Object
• DataReader Object
• DataAdapter Object
• DataSet Object
• DataView Object
• Use ADO.NET to access data in an application
108. Command Object
• Information submitted to a database as a query via a
Connection object
• Two provider-specific classes
o SqlCommand
o OleDbCommand
• Input and output parameters are supported, along with
return values as part of the command syntax
• Results are returned in the form of streams. Accessed
by:
o DataReader object
o DataSet object via a DataAdapter
109. Agenda
• ADO versus ADO.NET
• ADO.NET Architecture
• Connection Object
• Command Object
• DataReader Object
• DataAdapter Object
• DataSet Object
• DataView Object
• Use ADO.NET to access data in an application
110. DataReader Object
• Provides methods and properties that deliver
a forward-only stream of data rows from a
data source
• When a DataReader is used, parts of the
ADO.NET model are cut out, providing faster
and more efficient data access
112. Agenda
• ADO versus ADO.NET
• ADO.NET Architecture
• Connection Object
• Command Object
• DataReader Object
• DataAdapter Object
• DataSet Object
• DataView Object
• Use ADO.NET to access data in an application
113. DataAdapter Object
• Provides a set of methods and properties to retrieve
and save data between a DataSet and its source data
store
• Allows the use of stored procedures
• Connects to the database to fill the DataSet and also
update the database
114. Agenda
• ADO versus ADO.NET
• ADO.NET Architecture
• Connection Object
• Command Object
• DataReader Object
• DataAdapter Object
• DataSet Object
• DataView Object
• Use ADO.NET to access data in an application
115. DataSet Object
• Replaces the ADO Recordset
• Represents a cache of data that contains tables,
columns, relationships, and constraints, just like a
database
• Regardless of where the source data comes from,
data can all be placed into DataSet objects
• Tracks changes that are made to the data it holds
before updating the source data
• DataSet are also fully XML-featured
• Works with all current models of data storage:
flat, relational, and hierarchical
116. Agenda
• ADO versus ADO.NET
• ADO.NET Architecture
• Connection Object
• Command Object
• DataReader Object
• DataAdapter Object
• DataSet Object
• DataView Object
• Use ADO.NET to access data in an application
117. DataView Object
• Provides methods and properties that enable
UI objects such as a DataGrid to bind to a
DataSet
• A view of the data contained in the DataSet
• Only used in conjunction with a DataSet
118. Agenda
• ADO versus ADO.NET
• ADO.NET Architecture
• Connection Object
• Command Object
• DataReader Object
• DataAdapter Object
• DataSet Object
• DataView Object
• Use ADO.NET to access data in an application