The .NET Framework
The .NET Framework
The .NET Framework
NET framework
Chapter One: Introduction to .NET framework Before emergency of .NET framework, programmers used a
1.1 Chapter objectives number of tools to write programmers as depicted before
By the end of this, learners should be able to: ▪ Windows GUI development: Win32 API, MFC, Visual
v). Understand how compilation is done by .NET framework It’s the traditional software development for the Windows. It has
1.2 Life before .NET programming memory management and pointer arithmetic.
1
Edward Kioko|Email:-kioko@cuea.edu|Mobile number: +725-695-782| © 2020
CMT 307-.NET programming -Introduction to .NET framework
approach
However, C++ remains a difficult and error-prone experience.
classes that facilitate the construction of Win32 applications. applications unless you are willing to drop down to low-level
2
Edward Kioko|Email:-kioko@cuea.edu|Mobile number: +725-695-782| © 2020
CMT 307-.NET programming -Introduction to .NET framework
1.2.4 Life As a Java/J2EE Programmer Component Object Model (COM) is Microsoft’s previous
providing programmers with a large number of predefined C++ programmers can build COM classes that can be
“packages” that contain various type definitions. used by VB6. Delphi programmers can use COM classes
built using C.
However, java has a number of limitations such as limited It has a number of challenges such as language independence
ability to access non-Java APIs, little support for true cross- is limited, doesn’t support for classical inheritance) and its
language integration and it’s not appropriate for many extremely complex under the hood.
3
Edward Kioko|Email:-kioko@cuea.edu|Mobile number: +725-695-782| © 2020
CMT 307-.NET programming -Introduction to .NET framework
features into its family of operating systems and products. 1.3 .Net framework
The result of the above is completely unrelated syntaxes e.g. Applications, mobile applications, Desktop based applications
JavaScript has a syntax much like C, while VBScript is a subset within Microsoft environment. It’s consistent object-oriented
of VB6 which results to a highly confused mishmash of providing a portable as well as managed environment
system e.g. An “int” in JavaScript is not quite the same as an It provides tools and technologies necessary compile time and
“Integer” in VB6. The rescuer is Microsoft .NET framework runtime foundation to build and run any language that conforms
4
Edward Kioko|Email:-kioko@cuea.edu|Mobile number: +725-695-782| © 2020
CMT 307-.NET programming -Introduction to .NET framework
Oriented Application .
XML and SOAP and is towards more open standards rather than
Fig:1.0-.NET is cross platform
Microsoft its proprietary tendencies. It offers a fundamental shift
.NET is motivated by a number of factors such as in Microsoft strategy by moving application development from
i. popularity of electronic devices meaning it’s capable of client-centric to server-centric.
providing interaction between wide varieties of devices
such as cell phones, Personal Digital Assistants, .NET framework offers programmers with a number of services
5
Edward Kioko|Email:-kioko@cuea.edu|Mobile number: +725-695-782| © 2020
CMT 307-.NET programming -Introduction to .NET framework
Runtime).
The main two components of .Net Framework are Common Fig 1.1:-NET architecture
1.4.1. Common Language Runtime (CLR)
Language Runtime (CLR) and .Net Framework Class Library
(FCL) which provides a core services such as ASP.NET, It’s the engine behind the .NET framework that handles
windows, ADO.NET, windows forms, XML support e.tc
execution of all managed application code. It works as a
6
Edward Kioko|Email:-kioko@cuea.edu|Mobile number: +725-695-782| © 2020
CMT 307-.NET programming -Introduction to .NET framework
Language Specification (CLS). 11) Interoperation between managed code, COM objects
Some of the services provided CLR include: and pre-existing DLLs (unmanaged code and data)
2) Application memory isolation 13) Support for developer services (profiling, debugging,
etc.)
3) Garbage collection
5) Thread execution
7
Edward Kioko|Email:-kioko@cuea.edu|Mobile number: +725-695-782| © 2020
CMT 307-.NET programming -Introduction to .NET framework
1.4.2. . Net Framework Class Library (FCL) interface development. It’s a super set of what developers
all .NET enabled languages. The Classes are accessed by ▪ Window forms
namespaces, which reside within Assemblies. The System It’s a framework used to design rich clients for windows
Namespace is the root for types in the .NET Framework. platform can be done using Windows Forms which offers
It provides the core Web infrastructure such as Web Forms for inheritance
8
Edward Kioko|Email:-kioko@cuea.edu|Mobile number: +725-695-782| © 2020
CMT 307-.NET programming -Introduction to .NET framework
support XML
9
Edward Kioko|Email:-kioko@cuea.edu|Mobile number: +725-695-782| © 2020
CMT 307-.NET programming -Introduction to .NET framework
system. The JIT converts the MSIL code into native code to
which is Operating System specific, the overall effect being the Fig 1.5 :- CLR execution
same IL code being able to run on different OS. There is some
During compilation, metadata is always generated and stored
initial performance cost, but the jitted code is cached for further
with the compiled code in a file known as manifest which
execution. A big advantage is CLR can target the specific
contains information about the members, types, references and
architecture in which the code is executing, so some
all the other data that the Common Language Runtime
performance gains are possible.
10
Edward Kioko|Email:-kioko@cuea.edu|Mobile number: +725-695-782| © 2020
CMT 307-.NET programming -Introduction to .NET framework
modifications to code.
11
Edward Kioko|Email:-kioko@cuea.edu|Mobile number: +725-695-782| © 2020
CMT 307-.NET programming -Introduction to .NET framework
2. Interoperation between managed code and unmanaged 1.7 Common Language Infrastructure (CLI)
code (COM, DLLs).
CLI allows for cross-language development.
3. Managed code environment
12
Edward Kioko|Email:-kioko@cuea.edu|Mobile number: +725-695-782| © 2020
CMT 307-.NET programming -Introduction to .NET framework
13
Edward Kioko|Email:-kioko@cuea.edu|Mobile number: +725-695-782| © 2020
CMT 307-.NET programming -Introduction to .NET framework
Not all languages support all CTS types and features e.g.
does not
.NET languages are not compiled to machine code. They are Any language that conforms to the CLS is a .NET language and
compiled to an Intermediate Language (IL). CLR accepts the IL
it has the ability to take full advantage of FCL. This will ensure
code and recompiles it to machine code.
interoperability between languages.
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 Some of those rules and standards imposed by CLR for example:
14
Edward Kioko|Email:-kioko@cuea.edu|Mobile number: +725-695-782| © 2020
CMT 307-.NET programming -Introduction to .NET framework
2. Data types, language libraries ❑ J2EE- its platform Independent but Java
Development Kit (JDK) should exist on target
3. Error and exception handling
machine
4. Interactive Development Environment (IDE)
❑ .NET-Supports Windows platform but Common
1.8 Comparison & contrast of .NET & J2EE Architecture
Language Runtime (CLR) should exist on target
We compare the two frameworks from the following machine. Can also support other platforms provided it
perspectives
has its own JIT complier.
▪ Execution Engine
▪ Language support
❑ J2EE-Java source code compiles into machine-
independent byte code. The Runtime Environment ❑ J2EE-Tied to Java but supports other languages via
❑ .NET-Any compliant language compiles into ❑ .NET-its Language independent supporting any
MSIL/IL/CIL. The Runtime environment is language if mapping exists from that language to
Common Language Runtime( CLR)
IL
Both JVM and CLR support services, such as code
▪ Tools support
verification, garbage collection, and code security.
❑ J2EE-there are many IDE for programming in Java
▪ Cross platform portability
e.g. NetBeans, eclipse, blueJ,Jcreator,JDeveloper,
android studio
15
Edward Kioko|Email:-kioko@cuea.edu|Mobile number: +725-695-782| © 2020
CMT 307-.NET programming -Introduction to .NET framework
16
Edward Kioko|Email:-kioko@cuea.edu|Mobile number: +725-695-782| © 2020