Unit-1
Unit-1
Unit 4: Database Programming with ADO.NET and Reports - The ADO.NET architecture
(connected and disconnected mode) - ADO.NET Data providers, Dataset, DataAdapter,
DataReader - Working with Data Controls; Design time data binding; Runtime data
binding; Working with Stored Procedures, Generating reports
Reference Books:
1. C# and the .NET Platform by Andrew Troelsen : APress
2. C# The Basics by Vijay Mukhi : BPB
3. C# Essentials by Ben Albabari : O’Reilly
4. Professional C# by Simon Robinson : Wrox
5. ASP.NET - A Beginner’s guide by Dave Mercer : TMH
6. Professional ASP.NET : Wrox.
7. ASP.NET Programmer’s Reference : Wrox
8. ADO.NET Programmer’s Reference : Wrox.
9. Professional C# 2008 by Christian Nagel : Wrox
10. C# The Nuts & Bolts by Akash Sarat & Sonal Mukhi : BPB
11. C# Made Simple : BPB Publication
12. C# 3.0 Unleashed: With the .NET Framework 3.5 by Joseph Mayo : Sams
Unit 1
Introduction to .NET Framework - Architecture of .NET Framework – BCL (Base Class
Library), CLR (Common Language Runtime), Etc. - .NET Languages – Introduction,
Types of Applications Supported by .NET Technology - Managed Code, Compilation to
Intermediate Language, Just-In-Time Compilation, Garbage Collection, Assemblies and
the GAC
The .Net framework consists of developer tools, programming languages, and libraries
to build desktop and web applications.
.NET is a framework tool that supports many programming languages and many
technologies, .NET support 60+ programming languages.
In 60+ programming languages, 9 are designed by Microsoft and the remaining are
designed by non-Microsoft.
.Net Framework Architecture is a programming model for the .Net platform that
provides an execution environment and integration with various programming
languages for simple development and deployment of various types of applications.
It is a framework developed by Microsoft and it basically runs on Microsoft windows. Its
first beta version was 1.0 which was released in the year 2002.
It is a framework for developing a console base, window-based application, and web-
based application.
This framework supports many programming languages like C# and Visual Basics.
So it’s easy for the developer to choose any language to develop their required
application.
It consists of class libraries and reusable components.
Components of .NET Framework Architecture
The architecture of the .net framework is based on .net component.
Let’s have a look at its component and its description of its architecture with the help of
its diagram.
.Net Framework is a platform that provides tools and technologies to develop Windows,
Web and Enterprise applications. It mainly contains two components,
1. Common Language Runtime (CLR)
2. .Net Framework Class Library.
Programmatically, when our program needs memory, CLR allocates the memory for
scope and de-allocates the memory if the scope is completed.
Language Compilers (e.g. C#, VB.Net, J#) will convert the Code/Program to Microsoft
Intermediate Language (MSIL) intern this will be converted to Native Code by CLR. See
the below Fig.
There are currently over 15 language compilers being built by Microsoft and other
companies also producing the code that will execute under CLR.
Suppose we wrote a program and it needs memory, CLR now allocates the memory for
the program in scope and de-allocates the memory when it is not required or it is
completed.
This is also called as Base Class Library and it is common for all types of applications i.e.
the way you access the Library Classes and Methods in VB.NET will be the same in C#,
and it is common for all other languages in .NET.
The following are different types of applications that can make use of .net class library.
Windows Application.
Console Application
Web Application.
XML Web Services.
Windows Services.
In short, developers just need to import the BCL in their language code and use its
predefined methods and properties to implement common and complex functions like
reading and writing to file, graphic rendering, database interaction, and XML document
manipulation.
Below are the few more concepts that we need to know and understand as part of this
.Net framework.
It describes set of data types that can be used in different .Net languages in common.
(i.e), CTS ensures 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.
Value Types:
Value types directly contain their data, and instances of value types are either allocated
on the stack or allocated inline in a structure. Value types can be built-in (implemented
by the runtime), user-defined, or enumerations.
Reference types:
Reference types store a reference to the value's memory address, and are allocated on
the heap.
Reference types can be self-describing types, pointer types, or interface types.
The type of a reference type can be determined from values of self-describing types.
Self-describing types are further split into arrays and class types.
The class types are user-defined classes, boxed value types, and delegates.
It is a sub set of CTS and it specifies a set of rules that needs to be adhered or satisfied
by all language compilers targeting CLR.
It helps in cross language inheritance and cross language debugging.
It describes the minimal and complete set of features to produce code that can be
hosted by CLR.
It ensures that products of compilers will work properly in .NET environment.
Sample Rules:
1. Representation of text strings
2. Internal representation of enumerations
3. Definition of static members and this is a subset of the CTS which all
.NET languages are expected to support.
4. Microsoft has defined CLS which are nothing but guidelines that
language to follow so that it can communicate with other .NET
languages in a seamless manner.
Benefits of .Net Framework:
Using this model you can do different task such as connecting to and retrieving data
from databases, and reading from and writing to files.
.Net framework provides feature called CLR, which automatically tracks the resource
usage and relieves users from the task of manual resource management.
Ease of deployment:
In most cases, to install an application, you need to copy the application, along with its
component, on the target computer.
An assembly is compiled code library used for deployment, versioning and security.
There are two types: Proccess assemblies (.exe) and Library assemblies (.dll)
1. The .Net framework has one or more language compilers, such as Visual Basic,
C#, Visual C++, JScript, or one of many third-party compilers such as an Eiffel,
Perl, or COBOL compiler.
2. Anyone of the compilers translates your source code into Microsoft Intermediate
Language (MSIL) code.
3. For example, if you are using the C# programming language to develop an
application, when you compile the application, the C# language compiler will
convert your source code into Microsoft Intermediate Language (MSIL) code.
4. In short, VB.NET, C#, and other language compilers generate MSIL code. (In other
words, compiling translates your source code into MSIL and generates the
required metadata.)
5. Currently "Microsoft Intermediate Language" (MSIL) code is also known as the
"Intermediate Language" (IL) Code or "Common Intermediate Language" (CIL)
Code.
2. Runtime process.
1. The Common Language Runtime (CLR) includes a JIT compiler for converting
MSIL to native code.
2. The JIT Compiler in CLR converts the MSIL code into native machine code that is
then executed by the OS.
3. During the runtime of a program, the "Just in Time" (JIT) compiler of the
Common Language Runtime (CLR) uses the Metadata and converts Microsoft
Intermediate Language (MSIL) into native code.
The Garbage collection is very important technique in the .Net framework to free the
unused managed code objects in the memory and free the space to the process.
The garbage collection (GC) is new feature in Microsoft .net framework. When we have a
class that represents an object in the runtime that allocates a memory space in the heap
memory. All the behavior of that objects can be done in the allotted memory in the heap.
Once the activities related to that object is get finished then it will be there as unused
space in the memory.
The earlier releases of Microsoft products have used a method like once the process of
that object get finished then it will be cleared from the memory. For instance Visual
Basic, An object get finishes that work then there we have to define a "nothing" to that
object. So, it clears the memory space to the processors.
Microsoft was planning to introduce a method that should automate the cleaning of
unused memory space in the heap after the life time of that object. Eventually they have
introduced a new technique "Garbage collection". It is very important part in the .Net
framework. Now it handles this object clear in the memory implicitly. It overcomes the
existing explicit unused memory space clearance.
Implicit Garbage Collection should be handled by the .Net framework. When object is
created then it will be placed in the Generation 0. The garbage collection uses an
algorithm which checks the objects in the generation, the objects life time get over then
it will be removed from the memory. The two kinds of objects. One is Live Objects and
Dead Objects. The Garbage collection algorithm collects all unused objects that are dead
objects in the generation. If the live objects running for long time then based on that life
time it will be moved to next generation.
The object cleaning in the generation will not take place exactly after the life time over
of the particular objects. It takes own time to implement the sweeping algorithm to free
the spaces to the process.
Exception Handling
The Garbage collection has designed such a way that it can be implicitly handling to
collect the free spaces in memory. But as I said it takes own time to uses the algorithm
to collect unused objects in the memory.
If we want to forces to collect unused objects or explicitly release particular object from
the memory. The code allows us to clear the object from the heap immediately.