Академический Документы
Профессиональный Документы
Культура Документы
NET Framework
The .NET Framework is a Microsoft's development platform. It offers to develop software applications. It was released by Microsoft Corporation in 2002. Later on, several improvements take place in .NET Framework, which makes it as much strong, advanced and more efficient platform for building different kinds of software applications. Why it is called as platform is, it acts as platform for multiple languages, tools and libraries. It offers visually stunning user experiences, which is mostly required today s competitive programming world. It offers much advanced security features never before. Supports dozens of languages like C#, VB.NET, VC++.NET, COBOL, Pascal, Python etc.
Hour 6 - Page 1 of 44
Foundation) offers developers support for 2D and 3D graphics, hardware accelerated effects, scalability to different form factors, interactive data visualization, and superior content readability.
.NET Framework) provides support for 3 Microsoft developed languages and several
other languages from other vendors.
Languages vendors
from
other
Hour 6 - Page 2 of 44
Forth, Fortran, Haskell, J#, Mercury, Mondrian, Oberon, Python, IronPython, RPG, Scheme, Small Talk, Standard ML
Modules of .NET
1. C#.NET (C Sharp.NET) (Language)
It is highly used .NET programming language, used by most of the .NET programmers. It borrows some programming features from C and some other programming features from C++ . In addition to these, it borrows few of the good features of java language. It is the object oriented programming language.
Hour 6 - Page 3 of 44
But in fact, it is used in very few of the projects in the real-time development world, because most of the programmers usually comes with C and C++ background; hence they feel comfortable with C# . It borrows some programming features from VB (Visual Basic) language. It is the object oriented programming language.
(Web Technology)
It is the Microsoft s web technology. It is used for web sites development. It offers much attractive and user friendly user interfaces in the server side applications. It is the new version to another Microsoft s technology called ASP (Active Server Pages), which is a famous web technology before introducing ASP.NET. It requires HTML for web page designing. It requires a .NET language (like C#, VB.NET, VC++.NET etc.) for server side logic implementation.
(Database Technology)
It offers necessary programming libraries to access the local / server databases. It is the new version to another Microsoft s technology called ADO (ActiveX Data Objects), which is a famous database technology, used with VB, VC++ and ASP languages. It requires a .NET language (like C#, VB.NET, VC++.NET etc.) for logic implementation.
Applications of .NET
Hour 6 - Page 4 of 44
1. Console Applications
These applications contains similar user interface to the operating systems like MSDOS and UNIX. Known as C.U.I (Character User Interface) applications. These are similar to C/C++ applications. These are smaller in size. Doesn t contain any graphical features like mouse pointer, colors, fonts, buttons etc.
2. Windows Applications
These applications are designed similar to the Windows operating system. Known as G.U.I (Graphical User Interface) applications. Offers graphical features like mouse pointer, colors, fonts, buttons, text boxes etc.
Hour 6 - Page 5 of 44
3. Windows Services
A Windows service is a long-running executable application. These can run only on windows platforms. These perform specific functions as background process. Doesn t contain user interface or doesn t require any user interaction. Windows services can be configured to start when the operating system is booted and run in the background as long as Windows is running, or they can be started manually when required. Examples: i. Windows Time. ii. Windows Audio. iii. Anti-Virus Security. iv. Database services like Sql Server, My Sql and Oracle etc. v. IIS State Services. vi. Battery Power Supply Status on Laptops.
Hour 6 - Page 6 of 44
etc. To see the all the installed windows services on the system, click on Start Control Panel Administrative Tools Services .
Hour 6 - Page 7 of 44
Hour 6 - Page 8 of 44
6. Web Services
Web Services are simple and easy to understand. These can be developed using again ASP.NET. These are also known as web applications similar to web sites . But Web sites expose certain user interface (in the form of web pages) to the end-user; Web services expose a certain programming logic which can be accessed through another web site. Examples: i. Online shopping requires credit card authentication. ii. www.way2sms.com accesses the mail services of Yahoo and Gmail.
Hour 6 - Page 9 of 44
Before .NET
Branches of Microsoft Programming:
In the late 1990s, Windows programming using the Microsoft platform had divided into a number of branches. n n n Most programmers were using Visual Basic (VB). Some other programmers were using Visual C++ (VC++) with MFC (Microsoft Foundational Classes). The remaining programmers were using C or C++ in a combination with raw Win32 API.
Hour 6 - Page 10 of 44
n n n
MFC was object-oriented, but was inconsistent and getting old and it is very much complex in actual coding. There is no a perfect platform independent language. There is no easier mobile based application development language.
Promises by Microsoft:
While introducing .NET Framework, Microsoft Corporation given a promise to the software industry to deliver a standard Framework which overcomes the old problems and along with following: n n n Multiple platforms: The system runs on a broad range of computers, from servers and desktop machines, smart phones and cell phones. Industry standards: The system uses industry standard communication protocols, such as XML, HTTP, SOAP, and WSDL. Security: The system can provide a much safer execution environment, which can t be hacked or robbed by others.
.NET Versions
.NET Framework Version Exact Version Number
Date of Release
Visual Studio
1.0.3705.0
1.1.4322.573
2.0.50727.42
Hour 6 - Page 11 of 44
3.0.4506.30
3.5.21022.8
Visual Studio 2010 (not yet released completely, but a beta version is available on internet)
Hour 6 - Page 12 of 44
Hour 6 - Page 13 of 44
Internet Connection (optional): (To get latest news from Microsoft s web site)
Processor: RAM: Minimum: 512 MB Recommended: 1 GB (or above) MS Windows (XP / 2003 / Vista / 2008 / Windows 7) Minimum: P-IV Recommended: Higher than P-IV
OS:
n n
Hard disk free space: n 4.2 GB (on system drive ( C: )) CD/DVD Drive (For Installation)
Internet Connection (optional) (To get latest news and updates from Microsoft s web site)
Advantages of .NET
Hour 6 - Page 14 of 44
n n n n n n n n n n n n n n n n
Supports multiple languages like VC#, VB.NET, VC++.NET, VJ#.NET etc., so that the programmer can write the code in his/her interested language. Offers more secured environment never before. Offers flexible data access with ADO.NET Supports to develop windows services and web services, which are necessary to handle in the live projects in the modern programming world. Supports to develop applications for small devices like PDA s, smart phones, mobile phones etc. Offers platform independency , because it supports to run the .NET applications on other platforms like UNIX, LINUX and Solaris etc., with .NET Mono framework. Offers easier and faster UI design (with drag and drop technique), when compared with the languages like Java. Offers the best debugging tools in the industry, which makes the programmer to easily fix the bugs. Offers improved object oriented programming features like properties, sealed classes, inner classes, delegates, enumerations, collections, interfaces, generics etc. Offers to share and reuse the code among multiple applications very easily, with the concept of Assemblies . Offers to write queries in the programming code itself, using the newly added feature called LINQ (Language Integrated Query). This is newly added feature in .NET 3.5. Offers faster and easier Deployment features, to generate Installer packages for installing the .NET application on the client systems. Offers to create multiple threads and also to manage them for creating Multi-Threaded Applications. Offers XML support and interaction, which is mostly required in the modern application development environment. Supports to create user defined graphics like lines, rectangles, bars, circles etc., very easily using GDI+ (Graphics Device Interface) concepts. Offers a new and attractive feature called WPF (Windows Presentation Foundation), which is built on DirectX and which enables the programmer to create 2-D and 3-D graphics, animation, games, audio and view players etc. This is newly added feature in .NET 3.5.
Hour 6 - Page 15 of 44
Offers another prestigious feature called WCF (Windows Communication Foundation), which integrates the network programming related libraries of .NET like .NET Remoting, SOAP enabled web services and message queues etc., which helps the programmer to develop service and network oriented applications using .NET. This is newly added feature in .NET 3.5.
Support for the most recent web technology called AJAX (Asynchronous JavaScript and XML) along with ASP.NET. As a result of AJAX, the developer can produce newer generation user experiences on the web. Ex: www.orkut.com.
Similarities
Sl. No 1 2 3 4 5 6 7 8 9 10 11 .NET and Java Both of these support to develop console applications, windows applications, web sites, web services etc. Both use their own intermediate language. Java calls it as byte code and .NET calls it as MSIL . Both are Object oriented programming languages. Both support Remoting. Both supports multi-threading. Both are platform independent. Both support web related languages like Java Script, XML, CSS etc. Both support the recent web development technology like AJAX. Both support Garbage collection , which automatically clears the un-used memory. Both support to develop the applications for small devices like PDA s, mobile phones, smart phones etc. Both offer better security features in their own style.
Differences
Sl. No 1 2 3 .NET It is cost effective. Costs more than $700 (nearly Rs. 35,000) Supports Language Independency (supports multiple languages) Offers IDE as Visual Studio by Java It is open source product, which can be freely downloaded on the Internet. Doesn t offer multiple languages Doesn t offer any IDE. But other IDE s by
Hour 6 - Page 16 of 44
4 5 6
Microsoft. Offers easiest and fastest application development, which indirectly reduces the cost of the software. Designing the UI is very much easy with Drag and Drop technique. AJAX is implementation is much easy.
other vendors such as Eclipse etc. Requires much time for the application development, which indirectly increases the cost of the software. UI Design requires much programmer s effort and stress. AJAX is implementation is much time taking process, requires much code to write.
Hour 6 - Page 17 of 44
Hour 6 - Page 18 of 44
n n
A namespace is nothing but a collection of classes. For example, all the classes for performing I/O operations are located in the System.IO namespace.
Hour 6 - Page 19 of 44
Manifest Versioning
Information about the assembly, such as identification, name, The version number of an assembly. Information that describes the types and methods of the assembly.
Types of Assemblies
n n Private Assemblies: The private assemblies are simple types. An assembly that can be used only within a software application is called as Private assembly . Shared Assemblies: An assembly that can be used by one or more software applications is called as Shared Assemblies .
Example:
To get a better idea of a MSIL file and its content, take a look at the following example, which has two console applications. One is written in C# and the other is written in VB.NET.
Hello, World
message in the
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace HelloWorldCS { class Program { static void Main(string[] args) { Console.WriteLine( Hello, World! ); Console.ReadLine(); } } }
The following VB.NET code displays the Hello, World message in the console window:
Module Module1 Sub Main() Console.WriteLine( Hello, World! ) Console.ReadLine()
Hour 6 - Page 20 of 44
Hour 6 - Page 21 of 44
Conclusion: The Main method of the VB.NET MSIL looks very similar to that of the C#.NET s MSIL program. The important thing to note here is that regardless of the language you use to develop your .NET applications, all .NET applications are compiled to the MSIL bytecode as this example shows. Note: MSIL can also be called as IL (Intermediate Language) and CIL (Common Intermediate Language).
Code in C#.NET
Code in VB.NET
C#.NET Compiler
VB.NET Compiler
Another Compiler
MSIL Code
Hour 6 - Page 22 of 44
Hour 6 - Page 23 of 44
Components of CLR
The CLR contains the following components. n n n n n Security Manager / Code safety verifier JIT Compiler Memory Manager Garbage Collector Exception Manager
3.
Hour 6 - Page 24 of 44
4.
JIT Compiler
n n As you seen in the diagram of RTE previously, the JIT compiler is responsible for compiling the MSIL code into the Native code . The native code is directly understandable by the system hardware.
5.
Memory Manager
n The Memory Manager component of CLR, allocates necessary memory for the variables and objects that are to be used by the application.
6.
Garbage Collector
n n This component of CLR de-allocates or cleans-up the un-necessary memory of the application, after usage automatically. Instead, in older languages such as C/C++ this kind of component is not available so that the programmer should free-up the memory explicitly using some code.
7.
Exception Manager
n n n An exception means Run time error . This component redirect the processor to execute the catch block or finally block, whenever an exception is occurred at run time. We can learn how to write these catch and finally blocks in C#.NET and VB.NET languages later.
Hour 6 - Page 25 of 44
System
Windows
Web
Drawing
Data
Xml
Linq
Threading
IO
Tex
Forms
UI
Printing
OleDb
SqlClient
OracleClient
HtmlControls
WebControls
Hour 1 - Page 26 of 44
n n
Initially, the Visual Studio 2008 will be opened along with Start Page . The start page is nothing but the welcome page, which contains Logo: A logo of Microsoft Visual Studio 2008 on the top of the start page. Recent Projects: List of most recently opened projects. If you click on any one, the project will be opened immediately. Getting started: Headlines of visual studio help for .NET beginners. If you click on any one head line, online help will be opened (if Internet connection is available). Visual Studio Headlines: The headlines about the latest releases of .NET and Visual Studio versions, updates, beta versions, service packs etc. If you click on any one head line, online help will be opened (if Internet connection is available). MSDN - Visual Studio: Most recent headlines of visual studio help from MSDN (Microsoft Developer Network). If you click on any one head line, online help will be opened (if Internet connection is available).
Hour 1 - Page 27 of 44
namespace MyApplication { class class1 { } class class2 .NET 3.5 and Visual Studio 2008 { } }
Hour 1 - Page 28 of 44
In the New Project dialog box, the left side panel displays the list of .NET languages like Visual C#
Hour 1 - Page 29 of 44
Visual Basic Visual C++ etc. The right side panel displays the list of project templates like Windows Forms Applications Class Library ASP.NET Web Application ASP.NET Web Service Application WPF Application WPF Browser Application Console Application WCF Service Application Windows Forms Control Library
Select the appropriate language and required project template. For example select Visual C# and Windows Forms Application .
Hour 1 - Page 30 of 44
Provide the following details: n n n Name: Specifies the name of the project. Ex: WindowsFormsApplication1. Location: Specifies the path, in which the project is to be stored. Solution Name: The actual name of the solution. (By default the solution will be created with one project, later you can add other projects to this solution if needed).
In the above screen, you can see an empty form created automatically, named as Form1 .
Hour 1 - Page 31 of 44
n n n
Each project will be created as a folder, and placed in the solution folder. All the files related to the project, will be placed in the project folder. The information about the solution members will be saved in a file called Solution file and it will be placed in the solution folder. When we double click on it, that solution will be opened in Visual Studio. The file extension of the solution file is .sln .
In the same way, the information about the project members will be saved in the Project file and it will be placed in the project folder. When we double click on it, that project will be opened in Visual Studio.
You can observe the project directory structure according to our previous example. Note: First, recollect the project name, project location and solution name from previous example.
Project Folder
Solution Folder:
Solution File
Hour 1 - Page 32 of 44
Hour 1 - Page 33 of 44
Project Folder:
bin: This folder contains the EXE file after compiling the project. obj: This folder contains the temporary files of the project, while compilation. Properties: This folder contains necessary files that contain information about the settings and resources related to the project. WindowsFormsApplication1 (Project File): This file contains the information about all the files related to the project; When you double click on it, the project will be opened in Visual Studio. Form1.cs: This file contains the executable code of Form1 . Form1.Designer.cs: This file contains the code related to the design of Form1. Program.cs: This file contains the code of Program class with Main() method.
Hour 1 - Page 34 of 44
Menu Bar
Tool Bars
Tabs
Form Designer
Solution Explorer
Toolbox
Properties window
1) Menu Bar: This bar contains the available menus in Visual Studio like File , Edit , View and Project etc. 2) Tool Bars: There are several toolbars in Visual Studio, which contain frequently used options in Visual Studio. 3) Tabs: Displays tabs; just click to open required tab. 4) Form designer: Used to view and edit the visual design of the form.
Hour 1 - Page 35 of 44
5) Code Window: This is where you write actual programming of your application. You can switch to this view, by right click on the form designer and choosing View Code (or) by pressing F7 key on the keyboard.
6) Solution Explorer: Explores the information about the solution and its members. 7) Properties: Displays the available properties and values for the selected solution, project, form or control; and also allows to change the property values. 8) Other: In addition to the above specified IDE components, some other components are also available docked at the bottom area of Visual Studio window like Output , Error List , Command window , Immediate window , Breakpoints . We discuss about these components whenever required, in upcoming chapters later.
Hour 1 - Page 36 of 44
n n
New
Project .
Select the language as Visual C# and select the project template as Console
Then enter the project name and location (with your choice) and click on OK.
Hour 1 - Page 37 of 44
C#.NET
Overview
n n n n n n It s a programming language, offered by .NET Framework. It is recommended for both .NET programming beginners and .NET professionals. This is the mostly used languages used by most of the IT companies today. It derives some programming features from C and C++ also. It is the object oriented programming language. The programmer, having knowledge in C and C++ can easily understand the programming in C#.
Hour 1 - Page 38 of 44
File Extensions in C#
n n Project File Extension: .csproj (means C Sharp Project) Code File Extension: .cs (means C Sharp)
Hour 1 - Page 39 of 44
To run the application, simply press F5 key on the keyboard. Then the application will be executed and output will be as follows.
Hour 1 - Page 40 of 44
Hour 1 - Page 41 of 44
2. Namespace declaration:
Here, a user define namespace is to be declared. Rule: In .NET applications, all the classes related to the project should be declared in one namespace. Syn: namespace namespacename { } Generally, the namespace name will be same as Project name.
2. Class declaration:
This is to declare the startup class of the project. In every .NET application (like Console and Windows Application), there should a startup class. In these applications, the startup class name should be Program . You can t change it. A startup class nothing but a class, which contains Main() method. Syn: class classname { }
3. Main() method:
As you know already in C/C++ languages, the Main() method is the Starting Execution Point of the application. When the application is executed, the Main() method will be executed first. This method contains the main logic of the application.
Hour 1 - Page 42 of 44
Hour 1 - Page 43 of 44
Syn:
Specifies that Main() is a static method; to enable JIT, to directly call Main() method directly, without creating an instance of Program class.
Means no return value Receives arguments sent to the Main() method in a string array format.
Hour 1 - Page 44 of 44