Professional Documents
Culture Documents
Programs written for the .NET Framework execute in a software environment (as
contrasted to hardware environment), known as the Common Language Runtime
(CLR), an application virtual machine that provides important services such as
security, memory management, and exception handling.
The class library and the CLR together constitute the .NET Framework.
The .NET Framework's Base Class Library provides user interface, data access,
database connectivity, cryptography, web application development, numeric
algorithms, and network communications.
Programmers produce software by combining their own source code with the .NET
Framework and other libraries.
The .NET Framework is intended to be used by most new applications created for the
Windows platform.
Microsoft also produces a popular integrated development environment largely
for .NET software called Visual Studio.
2)components of .NET :
A programming infrastructure created by Microsoft for building, deploying, and running
applications and services that use .NET technologies, such as desktop applications and
Web services.
ASP.NET.
CLR:
The Common Language Runtime (CLR) is a special run time environment that provides
the underlying infrastructure for Microsoft's .NET framework.
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 main function of Common Language Runtime (CLR) is to convert the Managed
Code into native code and then execute the Program.
This runtime is where the source code of an application is compiled into an intermediate
language called CIL , originally known as MSIL (Microsoft Intermediate Language).
When the program is then run, the CIL code is translated into the native code of the
operating system using a just-in-time (JIT) compiler.
This intermediate language is used to keep the environment platform-neutral and as a
result, supports all .NET languages such as C# or VB.NET.
General advantages:
Portability
Security
Interoperability
Flexibility
Short for Common Language Runtime, a runtime environment that manages the
execution of .NET program code and provides services such as memory and exception
management, debugging and profiling, and security.
The CLR is a major component of the .NET framework.
CLR also is known as the Virtual Execution System (VES).
FCL:
The Framework Class Library (FCL) is a standard library and one of the components of
Microsoft .NET Framework.
The .Net Framework Class Libraries (FCL) are arranged into a logical grouping
according to their functionality and usability is called Namespaces.
The Classes are accessed by namespaces, which reside within Assemblies.
The FCL is a collection of thousands of reusable classes (within hundreds of
namespaces), interfaces and value types.
The Base Class Library is a part of FCL and provides the most fundamental
functionality, which includes classes in namespaces System, System.CodeDom,
System.Collections, System.Diagnostics, System.Globalization, System.IO,
System.Resources and System.Text.[
The .Net Framework class library (FCL) classes are object oriented and easy to use in
program developments.
The services provided by the FCL include runtime core functionality (basic types and
collections, file and network I/O, accessing system services, etc.), interaction with
databases, consuming and producing XML, and support for building Web-based and
desktop-based client applications, and SOAP-based XML Web services.
ASP.NET:
ASP.NET is a web application framework developed and marketed by
Microsoft to allow programmers to build dynamic web sites, web
applications and web services.
It was first released in January 2002 with version 1.0 of the .NET Framework, and is the
successor to Microsoft's Active Server Pages (ASP) technology.
ASP.NET is built on the Common Language Runtime (CLR), allowing programmers to
write ASP.NET code using any supported .NET language.
Platform Dependency: The application targets to particular o/s is called platform dependent application.
Example:-Let an application is developed in vb6.0 language to windows o/s.
If we try to run that application to another o/s it is not going to executed, it is dependent
on that particular o/s.
Solution:- .NET language compiler will produce IL(Intermediate Language) code, it is
platform independent code. It is going to be executed on any o/s.
Error Handling: C language -> Defining constants for error handling
VB language > An error goto label
VC++ language -> An error goto label
Different language has got different approach for error handling this is called
unstructured error handling, it doesnt support cross language error handling.
One language produced code used by another language application is called language
interoperability.
Language interoperability can be achieved before .NET using COM (Component Object
Model).
COM comes with a set of drawbacks: COM is specific to windows OS
COM is object based, no inheritance is supported
Soluction:- .NET is providing Assemblies concept to overcome COM drawbacks towards
language interoperability.
Distributed Technology:-
As shown in above diagram the application is running in Rohini Branch but the actual
logic is performed in Main Branch.
This is possible due to distributed system where same application is running on different
branch but its actual logic or implementaion is performed in Main Branch with the
database.
Before .NET distributed technology can be implemented using DCOM (Distributed
COM).
DCOM comes with set of drawbacks: It supports microsoft application communication only under windows network
It doesnt support internet based approach
Solution:- .NET is providing Remoting, Web services & Windows Communication
Foundation (WCF) towards distributed system.
.NET APP > Remoting -> .NET App
[Windows] [Linux]
J2EE App -> Web Services > .NET App
[Windows] [Linux]
Mobile Normal Application [Smart device App]:It is used for developing games, editors, etc towards mobile device
Mobile Web Application:It is used for developing webpage towards mobile device
Before .NET mobile normal application can be developed using vc++ internal
programming, it will be very complex & time consuming.
Before .NET mobile web application development is not possible.
Solution:- .NET supports mobile normal app with easier approach by providing smart
device project
.NET supports mobile web app development with MMIT [Microsoft Mobile Internet
Toolkit]
Importance of DLL
1.Reusability
The changes to dll will reflected to all the application,this provides better
maintainance.
3.Language Interoperability:
As shown in above figure the application development for wipro company 20 employee
are involved. 10 employee are good VC++ programmer while rest employee are good in
VB programming.
The module developed by VB programmer are packaged into dll file and provides it to
VC++ programmer for application development.
Before .NET language interoperability can be achieved using COM (Component
Object Module).
COM comes with set of drawbacks, it is avoided in .NET by providing Assemblies
concept.
Difference Between EXE and DLL
EXE:
Exe is self executable code,it is called as standalone application [Desktop app].
Example:-To copy Dos cmd (copy.exe)
For windows o/s calculator (calc.exe)
For windows explorer (explorer.exe)
DLL(Dynamic Link Labrary):
DLL is not a self executable, it is called as library file. The code written in dll file is
substituted into exe.
It is similar to header file in C language.
.NET High Level Language
Intermediate Language is similar to assembly level language, developer cannot write IL
code towards application development, it will be very complex & time consuming
10
VB.NET
C#.NET
VC++.NET
Vj#.NET
Other companies also provides high level language are called third party language
o Cobol.NET
o Pascal.NET
o Fortan.NET
o Smalltalk.NET
o Python.NET
.NET supports 25 + high level language
Features of .NET
Now that we know some basics of .NET, let us see what makes .NET a wonderful
platform for developing modern applications.
Rich Functionality out of the box:
This means that as a developer you need not go into low level details
of many operations such as file IO, network communication and so on.
OOPs Support
11
Languages like Visual Basic.NET now support many of the OO features that were
lacking traditionally.
Even primitive types like integer and characters can be treated as objects
something not available even in OO languages like C++.
Multi-Language Support
This means that if you have skills in C++, you need not throw them but just
mould them to suit .NET environment.
Currently four languages are available right out of the box namely Visual
Basic.NET, C# (pronounced as C-sharp), Jscript.NET and Managed C++ (a
dialect of Visual C++).
There are many vendors that are working on developing language compilers for
other languages (20+ language compilers are already available).
The beauty of multi language support lies in the fact that even though the syntax
of each language is different, the basic capabilities of each language remain at par
with one another.
Multi-Device Support
Modern lift style is increasingly embracing mobile and wireless devices such as
PDAs, mobiles and handheld PCs. . .
.NET provides promising platform for programming such devices.
.NET Compact Framework and Mobile Internet Toolkit are step ahead in this
direction.
12
Before the introduction of .NET, COM was the de-facto standard for
componentized software development.
Companies have invested lot of money and efforts in developing COM
components and controls.
The good news is you can still use COM components and ActiveX controls
under .NET.
.NET still relies on COM+ for features like transaction management and object
pooling.
In fact it provides enhanced declarative support for configuring COM+
application right from your source code.
Your COM+ knowledge still remains as a valuable asset.
The main reason behind this was the philosophy of COM one version of
component across machine.
.NET ends this DLL hell by allowing applications to use their own copy of
dependent DLLs.
Also, .NET components do not require any kind of registration in system registry.
Now days it is hard to find a programmer who is unaware of XML. XML has
gained such a strong industry support that almost all the vendors have released
some kind of upgrades or patches to their existing software to make it XML
compatible.
Currently, .NET is the only platform that has built with XML right
into the core framework.
.NET tries to harness power of XML in every possible
way.
In addition to providing support for manipulating and transforming XML
documents,
.NET provides XML web services that are based on standards like
HTTP, XML and SOAP.
13
Since, most of the configuration is done via configuration files, there is no need to
sit in front of actual machine and configure the application manually.
This is more important for web applications; simply FTPing new configuration
file makes necessary changes.
Security
Features such as type safety, code access security and role based authentication
make overall application more robust and secure.
14
15
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.
(or)
CLR can understand only one language IL [Intermediate Language]
Types supported by IL is called CTS
Basic types supported by IL: byte, int16, int32, uint16, uint32
User defined types: Structure, Class, Interface
Classification of Types:
The CTS can be classified into the following two general categories that are further divided
into subcategories:
Value Types: Contain data assigned by the user. The objects of the Value types are allocated
on the stack. Value types can be built-in, user-defined, or enumerations.
Reference Types: Contain the reference of the datas memory address. The objects of the
Reference types are allocated in a heap. They can be pointer types, interface types, or selfdescribing types. The self-describing types can be arrays and class types.
The Base class of all the types is the System.Object class.
The following figure shows the hierarchy of the types:
16
Runtime Engine
17
.NET framework consist of two parts:1. Language Libraries:It includes the classes and methodes for application development
2. Runtime Engine:It mainly carries out the execution of developed application
Runtime Engine is a software component to perform code conversion, threading, memory
management
Input Code > Runtime Engine -> Output Code
Java is providing runtime engine called JVM [Java Virtual Machine]
Byte Code > JVM > o/s Native Code
.NET is providing runtime engine called CLR [Common Language Runtime]
IL Code > CLR > o/s Native Code
IL code is platform independent code
CLR is layer above o/s
18
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.
(or)
The set of types to be supported by .NET high level language [vb.net, c#.net] is called
common language specification
It is subset of CTS.
19
Just In Time (JIT) compilation is used to run at high speed, after an initial phase of slow
interpretation.
Just In Time Compiler (JIT) code generally offers far better performance than
interpreters.
.Net Namespaces
The .NET Framework class library has thousands of classes which are needed for
developing and deploying solutions.
In order to organize all those classes for ease of use .NET Framework uses namespaces.
This Gives the Classes their own space and prevents conflicts between the various names
in these classes.
For instance if two classes contain a method Paint(), then to avoid conflicts in names we
can place these classes in two different namespaces.
Thus namespaces allow classes to be grouped in a consistent, hierarchical manner.
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.
Garbage Collection:
The .Net Framework provides a new mechanism for releasing unreferenced objects from
the memory (that is we no longer needed that objects in the program) ,this process is
called Garbage Collection (GC).
20
21
dll hell:Previously, before .NET, this used to be a major issue.
"DLL Hell" refers to the set of problems caused when multiple applications
attempt to share a common component like a dynamic link library (DLL) or a
Component Object Model (COM) class.
In the most typical case, one application will install a new version of the
shared component that is not backward compatible with the version already
on the machine.
Although the application that has just been installed works well, existing
applications that depended on a previous version of the shared component
might no longer work.
In some cases, the cause of the problem is even more subtle.
In many cases there is a significant delay before a user discovers that an
application has stopped working.
As a result, it is often difficult to remember when a change was made to the
machine that could have affected the application.
A user may remember installing something a week ago, but there is no
obvious correlation between that installation and the behavior they are now
seeing.
The reason for these issues is that version information about the different
components of an application aren't recorded or enforced by the system.
Also, changes made to the system on behalf of one application will typically
affect all applications on the machine.
One reason why it was hard to build an isolated application was the run-time
environment typically allowed the installation of only a single version of a
component or an application.
This restriction means that component authors must write their code in a way
that remains backward compatible, otherwise they risk breaking existing
applications when they install a new component.
In practice, writing code that is forever backward compatible is extremely
difficult, if not impossible.
Also components were shared because disk space and memory was
expensive.
In the past few years, hard disk and memory prices have dropped
dramatically, and disk space is no longer a premium.
22
But as applications have increased in size and in modularity not so long ago
many applications were entirely self-contained in a single .exe file - the DLL
sharing issue has not been addressed, and the problem has grown over time.
.NET DLL
Com Dll is a binary standard towards .Net Dll contains IL code towards
Windows o/s.
CLR.
Com doesnt support inheritance, it is .Net Dll support inheritance, it is
object based.
object oriented.
Com Dll is invalid without registry
entry in o/s, this is drawback when
dll is required for specific
application.
CIL
Cobol
Lisp
NetCOBOL
(Fujitsu)
Net Express
(Micro
DotLisp
IronScheme
L#
Ruby
IronRub
y
Ruby/.N
ET
Bridge
23
VB .NET
(Microsoft)
VB .NET
(Mono)
BETA
Boo
BlueDragon
C
lcc
cscc
C#
C#
(Microsoft)
C# (Mono)
Cw
C++
(Microsoft)
Cat
Focus)
CQL
CULE.NET
E#
Eiffel
F#
Forth
Fortran
Fortran
(Lahey)
Fortran
(Silverfrost)
Haskell (VHS)
IronPython
Java
J#
(Microsoft)
Java
(IKVM .NET)
JNBridge
JScript .NET
Lego.NET
FOIL
leXico
LOLCODE
Lua.NET
M#
Mercury
Metaphor
MixNet
Mondrain
Nermerle
Oberon
Ook# .NET
OMeta#
Pan#
Pascal
Chrome
Delphi
Component
Pascal
Ruby.NE
T
Smalltalk
S#
#Smallt
alk
Smalltal
k and
.NET
Scala
SML .NET
Spec#
Tachy
TickleSharp
Zonnon
PerlNET
PHP
Prolog
24
25
Visual Basic .NET comes with features such as a powerful new forms designer, an
in-place menu editor, and automatic control anchoring and docking.
Visual Basic .NET delivers new productivity features for building more robust
applications easily and quickly.
With an improved integrated development environment (IDE) and a significantly
reduced startup time, Visual Basic .NET offers fast, automatic formatting of code
as you type, improved IntelliSense, an enhanced object browser and XML
designer, and much more.
With Visual Basic .NET we can create Web applications using the shared Web
Forms Designer and the familiar "drag and drop" feature.
You can double-click and write code to respond to events.
Visual Basic .NET 2003 comes with an enhanced HTML Editor for working with
complex Web pages.
We can also use IntelliSense technology and tag completion, or choose the
WYSIWYG editor for visual authoring of interactive Web applications.
Simplified Deployment
With Visual Basic .NET we can build applications more rapidly and deploy and
maintain them with efficiency.
Visual Basic .NET 2003 and .NET Framework 1.1 makes "DLL Hell" a thing of
the past. Side-by-side versioning enables multiple versions of the same
component to live safely on the same machine so that applications can use a
specific version of a component. XCOPY-deployment and Web auto-download of
Windows-based applications combine the simplicity of Web page deployment and
maintenance with the power of rich, responsive Windows-based applications.
You can tackle any data access scenario easily with ADO.NET and ADO data
access.
The flexibility of ADO.NET enables data binding to any database, as well as
classes, collections, and arrays, and provides true XML representation of data.
Seamless access to ADO enables simple data access for connected data binding
scenarios.
Using ADO.NET, Visual Basic .NET can gain high-speed access to MS SQL
Server, Oracle, DB2, Microsoft Access, and more.
26
Improved Coding
Visual Basic developers can have full access to the capabilities available in .NET
Framework 1.1.
Developers can easily program system services including the event log,
performance counters and file system.
The new Windows Service project template enables to build real Microsoft
Windows NT Services.
XML Web services enable you to call components running on any platform using
open Internet protocols.
Working with XML Web services is easier where enhancements simplify the
discovery and consumption of XML Web services that are located within any
firewall. XML Web services can be built as easily as you would build any class in
Visual Basic 6.0.
The XML Web service project template builds all underlying Web service
infrastructure.
Mobile Applications
27
Visual Basic .NET 2003 and the .NET Framework 1.1 offer integrated support for
developing mobile Web applications for more than 200 Internet-enabled mobile
devices.
These new features give developers a single, mobile Web interface and
programming model to support a broad range of Web devices, including WML 1.1
for WAPenabled cellular phones, compact HTML (cHTML) for i-Mode
phones, and HTML for Pocket PC, handheld devices, and pagers.
Please note, Pocket PC programming is not available in Visual Basic .NET
Standard, it requires Visual Studio 2003 Professional, or higher.
COM Interoperability
You can maintain your existing code without the need to recode.
COM interoperability enables you to leverage your existing code assets and offers
seamless bi-directional communication between Visual Basic 6.0 and Visual Basic
.NET applications.
In addition, full support for existing ADO code and data binding enable a smooth
transition to Visual Basic .NET 2003.
Upgrade Wizard
You upgrade your code to receive all of the benefits of Visual Basic .NET 2003.
The Visual Basic .NET Upgrade Wizard, available in Visual Basic .NET 2003
Standard Edition, and higher, upgrades up to 95 percent of existing Visual Basic
code and forms to Visual Basic .NET with new support for Web classes and
UserControls.
28
a debugger
Toolbox:
The Toolbox is a palette of developer objects, or controls, that are placed on forms or web
pages, and then code is added to allow the user to interact with them.
An example would be TextBox, Button and ListBox controls.
With these three controls added to a Windows Form object the developer could write
code that would take text, input by the application user, and added to the ListBox after
the button was clicked.
Solution Explorer:
This is a section that is used to view and modify the contents of the project.
A Visual Studio Windows Application Project will generally have a Form object with a
code page, references to System components and possibly other modules with special
code that is used by the application.
Properties Windows:
The properties windows shows all the control (like textbox) properties to be change at
design time.
29
Most of this properties can be change at run time with some code, but basically most of
this properties change the way the control is display on your application.
Do this
30
About the task you are
currently working on
By topic or activity
To get the
information
Do this
While working in a
dialog box
By searching for a
specific keyword
About contacting
Microsoft for
product support
Insert the MSDN CD ROM included with Visual Studio.NET 2003 and then
Run MSDN setup.
31
i.e. it saves
To save only the item you are currently working on..(form or code
module or any other component)
The most common type of errors, syntax errors, occur when the
compiler cannot compile the code.
Syntax error:
32
o
o
o
How to Debug?
Tools
Modern debuggers usually allow you to step through your program and
look at the values of variables
Also the debugger will allow you to set breakpoints, which are
statements in your programs that you mark and tell the debugger to
suspend program execution when it gets there.
Modern debuggers usually allow you to step through your program and
look at the values of variables
Also the debugger will allow you to set breakpoints, which are
statements in your programs that you mark and tell the debugger to
suspend program execution when it gets there.
Tools
33
Step Into
Step Out
Step Over
Now start the program by clicking the Run button on the toolbar or hitting the
F5 key.
This window displays status messages for various features in the IDE.
The window consists of multiple panes that can be accessed by the
combo box selection just below the title.
These separate panes can display build messages, debug messages, or
they can even be configured to output from .bat or .com files that
would normally show up in a DOS window.
To access the Output window, select Other Windows from the View
menu, and choose Output, or select CTRL+ALT+O.
Start the program again. Note the messages displayed at this point in
the Output window.
The Build pane should be visible as the application initializes and
messages relating to building and starting the program will scroll by. As
the form becomes visible, the Debug pane of the Output window will
be displayed.
If the Output window is not visible for any reason, simply select
CTRL+ALT+O at any time, or locate the tabs that will toggle between it
and the Command window.
The Debug pane of the Output window displays information regarding
the current execution of the program.
34
35
Within the Immediate Command window, we can now begin to test all
sorts of scenarios and see what expression is going to give the desired
result:
?int((EmpSalary + 1000)/1000) * 1000
?int((20000 + 1000)/1000) * 1000
RoundSalary = Math.Ceiling(EmpSalary/1000)*1000
We can skip over the statement in our code and instead execute
whatever statement we choose.
Place the mouse over the breakpoint and drag the yellow arrow down
to the TotalCost variable assignment below
Place the mouse over the breakpoint and drag the yellow arrow down
to the TotalCost variable assignment below.
Windows applications created with Visual Studio have the file name
extension .exe and can be run on any system that contains Microsoft
Windows and the necessary support files.
(Visual Basic installs these support filesincluding the .NET Framework
files automatically.)
Visual Studio can create two types of executable files for your project:
a debug build and a release build.
Debug builds are created automatically by Visual Studio when you
create and test your program
They are stored in a folder called bin\debug within your project folder
The debug executable file typically contains debugging information
that makes the program run slightly slower
Release builds are optimized executable files stored in the bin\release
folder within your project.
To customize the settings for your release build,
Click the [ProjectName] Properties command on the Project
menu,
there you see a list of options.
You can make necessary changes
Deploying Applications
36
o
o
o
o
o
o
o
Click OK to open the Setup Wizard. The Setup wizard window looks like the image
below:
37
Click next on the above pane to take you to second pane in the Wizard.
The new pane allows us to create deployment projects both for Windows and
Web Applications.
Here, select the radio button which says "Create a setup for Windows Application"
as this is deploying a windows application and click next.
It looks like the image below:
38
Clicking next opens a new pane which has options like Deploying only primary output
from the project or both the project and source code or content files.
Check the checkbox which you want, in this case check the checkbox that says
"Primary Output from Deploy" and click next.
It looks like the image below:
Clicking next opens a new pane which asks if you want any additional files to be
added. If you wish, you can include other files, like an icon for the application. In this
example don't include any files and click next. It looks like the image below:
39
Doing that brings up the last pane of the Setup Wizard which looks like the image
below. Click Finish on this pane.
Clicking finish opens up a File System window which looks like the image below.
40
This window allows us to create shortcuts to the application on the desktop and in
our Programs Menu.
To create a shortcut, right-click on the folder "User's Desktop" and select "Create
Shortcut to User's Desktop". Rename the shortcut to "Deployment".
If we want a shortcut to the application from our Programs Menu, right-click on
"User's Program Menu" folder and select "Create Shortcut to User's Program Menu".
Rename the shortcut to "Deployment".
Once you are finished with it, click on "Application Folder" and open it's properties.
In the properties window set the property "Always Create" to True.
Set the same for "User's Desktop" and "User's Programs Menu" folders.
If you want any additional information to include with the set-up project, like the
manufacturer, author etc, click on Setup1 project and open it's properties. You can
set additional information here.
Once your are done with it build the project by right-clicking on Setup1 and selecting
Build.
The building process status will be shown in the status bar at the bottom of visual
studio IDE.
This builds the application. The setup file is created in the debug folder of Setup1
project.
41