0% found this document useful (0 votes)
2 views49 pages

Chapter Two - Introduction To .Net Edited

Uploaded by

firaolfro
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views49 pages

Chapter Two - Introduction To .Net Edited

Uploaded by

firaolfro
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 49

CHAPTER TWO

Introduction to .NET
.NET Framework & Its
Architecture

Nov 22, 2025


Software Framework?
 A software framework is a universal, reusable
software platform used to develop applications,
products and solutions.

Event Driven Programming


 Software frameworks include:
 Support programs,
 Compilers,
 Code libraries,
 An application programming interface (API) and
 Toolsets that bring together all the different
components to enable development of a project or
solution. 2
.Net - What is It?

Nov 22, 2025


• Microsoft .NET is a Framework
• It is language neutral software which provides a
common platform for building, running and
experiencing the next generation of distributed
applications

Event Driven Programming


• Not a language
• It designed to fulfill the following objectives:
 Provide object-oriented programming
environment
 Provide environment for developing various types
of applications, such as Windows-based
applications and Web-based applications
 To ensure that code based on the .NET Framework 3
What is .NET? …

• .NET is a platform that provides a


standardized set of services.
 It’s just like Windows, except distributed
over the Internet.
 It exports a common interface so that it’s
programs can be run on any system that
supports .NET.
• A specific software framework
 Includes a common runtime
What is .NET …
 .NET platform infrastructure comprises five pillars
1. .NET Framework: may be viewed as is software development environment
or as a runtime engine for managed code.
2. Microsoft visual Studio.NET (the developers toolkit): is not an integral
of .NET, but it is an independent platform to provide all the tools required for
developers to build applications.
3. The .NET enterprise servers: These services include Microsoft SQL
server, Microsoft Exchange Enterprise Server, Microsoft Commerce Server, &
Microsoft Mobile Information Server, etc.
4. Microsoft Windows.NET: is a new OS over which the .NET is going to
work in the future.
5. Compact Real time for Mobile Devices: is runtime designed for mobile
devices that can run on Window CE (Embedded Compact) operating system.
5
.NET Framework
• Programming model for .NET
• Platform for running .NET managed code in a virtual
machine
• Provides a very good environment to develop
networked applications and Web Services
• Provides programming API and unified language-
independent development framework
.NET Framework …
.NET Framework Architecture
 ASP.NET: is a unified web development platform that provides necessary
services for developers to build enterprise web based applications .
 ADO.NET: provides a most general solution for data access and
manipulation.
 Web services: is a network interface to application functionality based on
standard internet technology.
 Winforms, which is a subset of .NET base classes, provides Graphical User
Interfaces.
 .NET support three type of interface: Window Forms, Web Forms and Console
Application.

 Common Language Runtime (CLR):- is an environment in which


programs are executed.
7
.NET Framework …
Common Language Runtime
 CLR manages code execution at runtime
 Memory management, thread management,
etc.

Common Language Runtime

Operating System
.NET Framework …
Base Class Library
 Object-oriented collection of reusable types
 Collections, I/O, Strings, …

.NET Framework (Base Class Library)

Common Language Runtime

Operating System
.NET Framework …
Data Access Layer
 Access relational databases
 Disconnected data model
 Work with XML

ADO .NET and XML

.NET Framework (Base Class Library)

Common Language Runtime

Operating System
.NET Framework …
ASP.NET & Windows Forms
 Create application’s front-end – Web-based user
interface, Windows GUI, Web services, …

ASP .NET Windows


Web Forms Web Services
Mobile Internet Toolkit
Forms

ADO .NET and XML

.NET Framework (Base Class Library)

Common Language Runtime

Operating System
.NET Framework …
Programming Languages
 Use your favorite language

C++ C# VB.NET Perl J# …


ASP .NET Windows
Web Forms Web Services
Forms
Mobile Internet Toolkit

ADO .NET and XML

.NET Framework (Base Class Library)

Common Language Runtime

Operating System
.NET Framework …
Common Language Specification

C++ C# VB Perl J# …

Common Language Specification


ASP .NET Windows
Web Forms Web Services
Forms
Mobile Internet Toolkit

ADO .NET and XML

.NET Framework (Base Class Library)

Common Language Runtime

Operating System
.NET Framework …
Visual Studio .NET

Visual Studio .NET


C++ C# VB Perl J# …

Common Language Specification


ASP .NET Windows
Web Forms Web Services
Forms
Mobile Internet Toolkit

ADO .NET and XML

.NET Framework (Base Class Library)

Common Language Runtime

Operating System
Common Type System (CTS)
• All .NET languages have the same primitive data types.
An int in C# is the same as an int in VB.NET
• When communicating between modules written in
any .NET language, the types are guaranteed to be
compatible on the binary level
• Types can be:
 Value types – passed by value, stored in the stack
 Reference types – passed by reference, stored in the heap
• Strings are a primitive data type now
.NET Framework Consists of:

Nov 22, 2025


1. Common Language Specification (CLS)
• Any language that conforms to the CLS is a .NET
language
A language that conforms to the CLS has the ability

Event Driven Programming



to take full advantage of the Framework Class Library
(FCL)
• CLS is standardized by ECMA
• It contains guidelines, that language should follow so
that they can communicate with other .NET
languages.
• It is responsible for Type matching (properly 16
.NET Framework Consists of:

Nov 22, 2025


1. Common Language Specification (CLS) …
• It performs the following functions:
• Establishes a framework that helps enable cross-
language integration, type safety, and high

Event Driven Programming


performance code execution
• Provides an object-oriented model that supports the
complete implementation of many programming
languages
• Defines rules that languages must follow, which helps
ensure that objects written in different languages can
interact with each other.
17
.NET Framework Consists of:

Nov 22, 2025


2. Framework Base Class Libraries (BCL)
 collection of ready-made reusable classes that work with
CLR
 consistent, object-oriented library of prepackaged

Event Driven Programming


functionality and Applications.
 Programmers using any of .NET languages can use these
classes to include in their applications.
 Examples of the classes provided by the library are:
 Database access and manipulation
 User Interface – Windows Forms, Web Forms, Web Services
 Security
 Encryption and decryption
 Provides the core functionality:
 ASP.NET, Web Services, ADO.NET, Windows Forms, IO, XML, etc. 18
.NET Framework Consists of:

Nov 22, 2025


2. Framework Base Class Libraries (BCL) …
Class Library is a comprehensive, object-oriented collection of
reusable types

Event Driven Programming


These class library can be used to develop applications that
include:
 Applications based on the latest innovations provided by

ASP.NET
 Traditional command-line applications
 Graphical user interface (GUI) applications

19
.NET Framework Consists of:

Nov 22, 2025


3. Common Language Runtime (CLR)
• Is language-neutral development & execution
environment that provides common runtime for
application execution.

Event Driven Programming


• Is common compiler for all Microsoft programming
language to one Machine Language.
• It allows programmers to write code in different
Microsoft languages of their choice, and ensure that the
parts can work together
• In addition it provides programmers with services for
memory management, data types, security etc.
20
.NET Framework Consists of:

Nov 22, 2025


3. Common Language Runtime (CLR) …
• It perform:
• Garbage collection
• Language integration
• Multiple versioning support (no more DLL hell!)

Event Driven Programming


• Integrated security
• CLR ensures:
• Establishes a framework that helps enable a common
runtime environment for all .NET languages
• Uses Common Type System (strict-type & code-verification)
• Memory allocation and garbage collection
• Intermediate Language (IL) to native code compiler. Which
Compiles MSIL code into native executable code
• Security and interoperability of the code with other 21
.NET Framework Consists of:

Nov 22, 2025


4. Windows Forms
 Framework for building rich clients.
 Provides rapid application development

Event Driven Programming


environment.
 Rich set of controls
 Data aware
 Printing support
 Unicode support
 UI inheritance
22
.NET Framework Consists of:

Nov 22, 2025


5. ASP.NET
 Platform services that allow to program Web
Applications and Web Services in any .NET
language.

Event Driven Programming


 Uses .NET languages to generate HTML pages.
 ASP.NET “Program” is compiled into a .NET class
and cached the first time it is called. All
subsequent calls use the cached version.
 ASP.NET has two components
1. Web Forms: a UI allows clean cut code
2. Web Services: A programmable application 23
.NET Framework Consists of:

Nov 22, 2025


6. ADO.NET (Data and XML)
 ADO.NET is a set of classes that expose data
access services for .NET Framework
programmers.

Event Driven Programming


 ADO.NET provides a rich set of components for
creating distributed, data-sharing applications.
 ADO.NET provides consistent access to data
sources such as SQL Server and XML, and to
data sources exposed through OLE DB and
ODBC.
 Data-sharing consumer applications can use
ADO.NET to connect to these data sources and 24
.NET Languages
 Over 36 languages supported today
• Languages provided by Microsoft
 C++, C#, J#, VB.NET, JScript
• Third-parties languages
 Perl, Python, Smalltalk, Cobol, Haskell, Mercury, Eiffel,
Oberon, Oz, Pascal, APL, CAML, Scheme, etc.
• Advanced multi-language features
 Cross-language inheritance and exceptions handling
• Object system is built in, not bolted on
 No additional rules or API to learn
Compilation in .NET

Nov 22, 2025


Code in another
Code in VB.NET Code in C# .NET Language

Event Driven Programming


Appropriate
VB.NET compiler C# compiler Compiler

IL(Intermediate
Language) code

CLR just-in-time
execution
26
Intermediate Language (IL)

Nov 22, 2025


 .NET languages are not compiled to machine
code. They are compiled to an Intermediate
Language (IL).
 CLR accepts the IL code and recompiles it to

Event Driven Programming


machine code. The recompilation is just-in-time
(JIT) meaning it is done as soon as a function or
subroutine is called.
 The JIT code stays in memory for subsequent
calls. In cases where there is not enough
memory it is discarded thus making JIT process
interpretive.
27
Uses of .NET Platform in App.
Dev’t

Nov 22, 2025


– Provides a consistent object-oriented
programming.
– Provides a code-execution environment that
minimizes software deployment.

Event Driven Programming


– Provides a code-execution environment that
promotes safe execution of code.
– To provide a code-execution environment that
eliminates the performance problems of
scripted or interpreted environments.
– To make the developer experience consistent
across widely varying types of applications,
such as Windows-based applications and Web- 28
C# (C-Sharp)

Nov 22, 2025


– Microsoft C# (pronounced C Sharp) developed
by Microsoft Corporation, USA
– New programming language that runs on
the .NET Framework

Event Driven Programming


– C# is simple, modern, type safe, and object
oriented
– C# code is compiled as managed code
– Combines the best features of Visual Basic, C+
+ and Java
– Versionable
– Compatible
– 29
Introduction to Visual

Nov 22, 2025


Studio.NET
 Development tool that contains a rich set of
productivity and debugging features.
 Types of applications we can create include:

Event Driven Programming


 Console Application – Usually Text only
application. Runs from a DOS or COMMAND PROMPT
screen.
 Windows Application – Graphical Interface user
application. Typical Windows application that you
normally use, such as MS WORD etc.
 Web Based Windows Application – Web
application that uses a Browser such as Internet
Explorer. 30
Nov 22, 2025
Visual Studio Environment
 Integrated Development Environment (IDE)
 Form Designer
 Editor for entering code

Event Driven Programming


 Compiler
 Debugger
 Object Browser

31
Visual Studio IDE Start Page

Event Driven Programming Nov 22, 2025


32
IDE New Project Dialog

Event Driven Programming Nov 22, 2025


33
Nov 22, 2025
IDE Main Window Components
 Toolbars
 Document Window
 Form Designer
 Solution Explorer

Event Driven Programming


 Properties Window
 The Name property of a control is used to refer to
the control in code.
 The Text property holds the words that the user
sees on the screen.
 Toolbox
 Server Explorer,…
34
IDE Main Window

Event Driven Programming Nov 22, 2025


35
Nov 22, 2025
IDE Main Window Components
Solution Explorer
 Presents a tree view
structure of files present in
the project.

Event Driven Programming


 By default a New Website
will contain:
• An App_Data folder
• A Default.aspx page
(including Default.aspx.cs)
To view Solution Explorer:
 Select View > Solution
Explorer
OR 36
Nov 22, 2025
IDE Main Window Components
Solution Explorer
 The Toolbar at the top of Solution Explorer
enables various tasks.
Code

Event Driven Programming


Refresh Copy Website

View Designer
Properties

Nest Related Files ASP.NET Configuration 37


Nov 22, 2025
IDE Main Window Components
Toolbox
 Holds the controls you place on a
form.
 There are various tool tabs available in
the Toolbox.

Event Driven Programming


 The controls in the IDE are presented
in a hierarchical manner (e.g.,
Standard Tab, Data Tab, Validation,
Navigation, WebParts etc.).
 Depending on the type of project
(application) the toolbox tabs will vary.
 To view the tool box:
 Select menu View > Toolbox OR
 Press buttons Ctrl+Alt+X or Ctrl+W, X
 You can also view the controls as icons 38
Nov 22, 2025
IDE Main Window Components
Property Window
 Used to view or change the properties
and events of a selected control during
design use the Properties Window
 To configure a control:

Event Driven Programming


 Click once to select it
 Press F4 or Select menu View > Properties
window
 Modify the appropriate properties in the
window
 There are various options provided for
viewing the properties of the selected
control, such as:
 Categorized view
 Alphabetical view 39
Creating a Program in C#
 Computer program is set of instructions which tell a computer what to do
 Programmers do not use machine language when creating computer programs
 Instead, tend to use high-level programming languages
 Each high-level language has its own syntax and limited set of vocabulary that is
translated into machine code by a compiler
 In addition to understanding syntax, a programmer must also understand
programming logic
 C# program consists of the following parts:−
 Namespace declaration
 Class
 Class methods
 Class attributes
 Main method
 Statements and Expressions
 Comments
40
Sample code
using System;
namespace HelloWorldApplication
{
class HelloWorld
{
static void Main(string[] args)
{
/* my first program in C# */
Console.WriteLine("Hello World");
Console.ReadKey();
} Output
}
Hello World!
}

41
Sample code …
 Let us look at the various parts of the given program
 Console is a class
 “This is my first C# program” is a literal string of characters
 using System;
 using keyword is used to include the System namespace in the program
 program generally has multiple using statements.
 namespace declaration
 is a collection of classes
 HelloWorldApplication namespace contains the class HelloWorld
 class declaration
 HelloWorld class contains the data and method definitions that your program uses
 Classes generally contain multiple methods
 Methods define the behavior of the class
 However, the HelloWorld class has only one method Main. 42
Sample code …
 Let us look at the various …
 Static
 keyword which means object is not required to access static
members. So it saves memory.
 Void
 return type of the method
 It does't return any value
 In such case, return statement is not required
 string[] args
 used for command line arguments in C#
 While running the C# program, we can pass values. These values are
known as arguments which we can use in the program. 43
Sample code …
 Let us look at the various …
 Main method
 entry point for all C# programs
 Whenever we run the C# program, Main() method is invoked first before any other
method. It represents start up of the program.
 states what the class does when executed
 Comment
 /*...*/ is ignored by the compiler and it is put to add comments in the program
 Console.WriteLine("Hello World");
 WriteLine is a method of the Console class defined in the System namespace
 This statement causes the message "Hello, World!" to be displayed on the screen.
 Console.ReadKey(); is for the VS.NET Users
 makes the program wait for a key press and it prevents the screen from running and
44
closing quickly when the program is launched from Visual Studio .NET
Compilation in .NET
Code in another
Code in VB.NET Code in C# .NET Language

Appropriate
VB.NET compiler C# compiler Compiler

IL(Intermediate
Language) code

CLR just-in-time
execution
45
Compilation and Execution by CLR

46
Compilation and Execution by CLR …
 A program written in VB, C# or any of the .NET compliant
languages is compiled with their respective compilers to
produce .EXE or .DLL file, containing the IL code and
metadata, that can be saved on to a disk or deployed on the
internet.
 Then execution, the IL code and any requested functionality
from the .Net base classes (libraries) is brought together.
 The just in time (JIT) compiler processes the combined code
creating managed native code, which can be executed on
the host CPU.
 Various JIT compilers are provided by the CLR, making it
possible for different computer architectures to execute IL.
47
Compiling & Executing Program
 After creating source code, you must do the following before viewing program output:
 Compile the source code into intermediate language (IL)
 Use C# just in time (JIT) compiler to translate the intermediate code into executable
statements
 If you are using Visual Studio.Net C# programs, take the ff steps −
 Start Visual Studio
 On the menu bar, choose File -> New -> Project.
 Choose Visual C# from templates, and then choose Windows.
 Choose Console/windows/web Application.
 Specify a name for your project and click OK button.
 This creates a new project in Solution Explorer.
 Write code in the Code Editor.
 Click the Run button or press F5 key to execute the project.
 Command Prompt window or graphical user interface (GUI) window appears that contains code result
48
Practical Intro. To MS VS.NET

Nov 22, 2025


2015
 Creating Project Using the Integrated
Development Environment
 Step 1: Open the Visual Studio IDE and invoke
the Start Page
 Step 2a: In the Start Page, select New Project

Event Driven Programming


 Step 2b: In the New Project Dialog select
Application Type
 Step 3: The IDE Main Screen: varies depending
on which type of application you have selected,
 Step 4: Set the Project Properties (StartUp
Object)
 Step 5: Create your program using the
components of the IDE Main Screen.
 Step 6: Compile or Build the Program. 49

You might also like