0% found this document useful (0 votes)
23 views

PT Unit1 V1

Uploaded by

jahangeerkingj
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)
23 views

PT Unit1 V1

Uploaded by

jahangeerkingj
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/ 59

ACHARIYA

COLLEGE OF ENGINEERING TECHNOLOGY


(Approved by AICTE New Delhi & Affiliated to
Pondicherry University) An ISO 9001 : 2008 Certified Institution

Department of Computer Science and Engineering

Subject Code : CS T54


Subject Name: PLATFORM TECHNOLOGY

Mrs. M.VishnuPriya., M.Tech


Assistant Professor
UNIT I - .NET FRAMEWORK
• NET Framework
• Common Language Runtime (CLR)
• .NET Framework Class Library
• .NET Windows Forms
• Uses of Web Forms & Web Services
• Common Language Runtime (CLR)
• Common Type System
• Microsoft Intermediate Language (MSIL)
• Components of the CLR
• Distinguish Between the .NET Compilers
• Organising and Executing Managed Code.
UNIT I - .NET FRAMEWORK
• NET Framework Class Library
• Namespace
• Input and Output
• Serialization
• Working with XML
• Remoting
• Enterprise Services
• Interoperability
• GUIs.
Why I should Learn .NET?
• 1. Career opportunities – Big Companies prefer
• 2. Why to Learn – Very Easy to learn
• 3. What famous – MVC Design Pattern – SharePoint
- .NET core
• 4. Advantage – Many Projects created using .NET
Client – Server Relationship
• Eg: Create Medical application for Hospital
Front End Back End

Dot Net SQL Server

Java Oracle

PHP MYSQL
Application

Windows Web
Application Application

• MS WORD, MS POWERPOINT ETC


• College Mgmt. System Website Creation
• Staff Mgmt. System • College Website
• Customer Mgmt System • Hospital Website
• Student Mgmt System, etc. • Railways
• Government Websites etc.
Microsoft Applications
Presentation Silverlight, Windows Mobile, Windows Office

Development/Application Microsoft .NET, Sharepoint

Database Microsoft SQL Server

Operating System Windows .NET Server 2000


UWP(Universal Windows Platform)

Microsoft DOT NET

Microsoft .NET Xamarin ( Mobile


.NET Core
Application)
.NET FRAMEWORK
• NET is a framework to develop software applications.
• It is designed and developed by Microsoft and the first beta version released in 2000.
• It is used to develop applications for web, Windows, phone.
• Moreover, it provides a broad range of functionalities and support.
• This framework contains a large number of class libraries known as Framework
Class Library (FCL).
• The software programs written in .NET are executed in the execution environment,
which is called CLR (Common Language Runtime). These are the core and essential
parts of the .NET framework.
• This framework provides various services like memory management, networking,
security, memory management, and type-safety.
• The .Net Framework supports more than 60 programming languages such as C#, F#,
VB.NET, J#, VC++, JScript.NET, APL, COBOL, Perl, Oberon, ML, Pascal, Eiffel,
Smalltalk, Python, Cobra, ADA, etc.
.NET FRAMEWORK
• The .NET Framework is composed of four main components:
1.Common Language Runtime (CLR)
2.Framework Class Library (FCL),
3.Core Languages (WinForms, C#, ASP.NET, and ADO.NET), and
4.Other Modules (WCF, WPF, WF, Card Space, LINQ, Entity Framework,
Parallel LINQ, Task Parallel Library, etc.)
• Microsoft offers four .NET languages—
• Visual Basic
• .NET, Visual
• C#,
• Visual C++ with managed extensions, and Jscript.
The Common Language Runtime

• It is a program execution engine that loads and executes the program.


• It converts the program into native code.
• It acts as an interface between the framework and operating
system.
• It does exception handling, memory management, and garbage
collection.
• Moreover, it provides security, type-safety, interoperability, and
portability.
CLR
MSIL
• .NET language compilers—e.g., C# and VB.NET— compile source code
into MSIL—a machine‐ independent, intermediate language.
• MSIL is subsequently compiled by the Just‐In‐Time (JIT) compiler into
machine language just prior to execution.
• The Native Image Generator Tool can also be used to convert MSIL
into machine language.
JIT( Just in Time)

• JIT is the process of compiling MSIL code units just when needed at
runtime.
• The JIT compiler in the Common Language Runtime (CLR) compiles
MSIL instructions to native machine code as a .NET application is
being executed.
• Compilation occurs when a method is called and is not compiled more
than once during program execution; because, JIT‐compiled code is
cached in memory.
JIT( Just in Time)
• Several JIT compilers exist, each targeting a different architecture, and the appropriate one will be used to
create the native code required.

• JIT are of three types:

 Pre JIT

 Econo JIT

 Normal JIT
Managed Code
• Code that is executed by the Common Language Runtime (CLR) is
called managed code.
• Managed code provides metadata to enable the CLR to handle
exceptions, locate methods encoded in assembly modules, and
manage security information.
• Managed code can access both managed data and unmanaged data.
Uses of Managed Code
 Complete object-oriented design.

 Very strong type safety.

 A good blend of Visual Basic simplicity and C++ power.

 Garbage collection.

 Syntax and keywords similar to C and C++.

 Use of delegates rather than function pointers for increased type safety and security. Function pointers are
available through the use of the unsafe C# keyword and the /unsafe option of the C# compiler (Csc.exe) for
unmanaged code and data.
Unmanaged Code
• It is, also called unsafe code, code that executes outside of the
control of the Common Language Runtime (CLR).
• Unmanaged code may perform unsafe operations such as pointer
arithmetic.
• Unmanaged code is used for accessing unmanaged memory, calling
Windows APIs, interfacing to COM components, and coding
performance‐critical methods which avoid the overhead of the CLR.
Unmanaged Code
FCL (Framework Class Library)
• It is a standard library that is a collection of thousands of
classes and used to build an application.
• The BCL (Base Class Library) is the core of the FCL and
provides basic functionalities.
Core Languages
• WinForms
• Windows Forms is a smart client technology for the .NET Framework, a set
of managed libraries that simplify common application tasks such as
reading and writing to the file system.
• Classes for building Windows graphical user interfaces (GUI) in any CLR –
based programming Language.
• ASP.NET
• ASP.NET is a web framework designed and developed by Microsoft.
• It is used to develop websites, web applications, and web services.
• It provides a fantastic integration of HTML, CSS, and JavaScript.
• Classes focused on building browser- accessible applications.
• It was first released in January 2002.
• ADO.NET
• ADO.NET is a module of .Net Framework, which is used to establish a
connection between application and data sources.
• Data sources can be such as SQL Server and XML.
• ADO .NET consists of classes that can be used to connect, retrieve, insert,
and delete data.

• Classes focused on accessing data stored in relational database management


system (DBMS)

• Software that uses .NET Framework is referred to as managed code.


The .NET Framework Class Library

• The .Net Framework library is exactly what its name suggests: a library of classes and other types that
developers can use to make their lives easier.
• While these classes are themselves written in C#, they can be used from any CLR-based language.
• Code written in C#, VB, C++, or any other language supported by the .Net Framework can create instances of
these classes and call their methods.
• That code can also rely on the CLR’s support for inherit from the library’s classes.
• Surveying the Library
• The contents of the .Net Framework class library are organized into a tree of namespaces. Each namespace
can obtain types, such as classes and interfaces, and other namespaces.
Namespaces in .NET Framework
• System:

•The root of the tree, this namespace contains all of the other namespaces in the .Net Framework class
library.

•System also contains the core data types used by the CLR. These types include several varieties of
integers, a string type, and many more.

• System. Web:

•This namespace contains types useful for creating Web applications, and like many namespaces, it has
subordinate namespaces.

• Developers can use the types in System.Web.UI to built Asp.NET browser applications, for example,
while those in System. Web. Services are used to build ASP.NET Web Services.
Namespaces in .NET Framework
• System. Data:

• The type in this namespace comprise ADO.NET.

• For Example, the connection class is used to establish connections to database management system (DBMS), while an instance
of the DataSet class can be used to cache and examine the results of a query issued against that DBMS.

• System.Windows.Forms:

• The types in this namespace make up Windows Forms, and they are used to build Windows GUIs.

• Rather than relying on language-specific mechanisms, such as the older Microsoft Foundation Classes (MFC) in C++, .Net
Framework applications written in any programming language use this common set of types to build graphical interfaces for Windows.

• System.EnterpriseServices:

• The types in this namespace provide services required for some kinds of enterprise applications. Implemented by COM+ in the pre-
NET world, these services include distributed transactions, object instance lifetime management, and more. The most important in this
namespace, one from which classes must inherit to use Enterprise Services, is the ServicedComponent class.
Namespaces in .NET Framework
 Microsoft.Csharp

• Contains classes that support compilation and code generation using the C# language.

 Microsoft.Jscript

• Contains classes that support compilation and code generation using the Jscript language.

 Microsoft.VisualBasic

• Contains classes that support compilation and code generation using the Visual Basic .NET language.

 System.CodeDom

• Contains classes that can be used to represent the elements and structure of a source code document.
Namespaces in .NET Framework
• System.XML:

•Types in this namespace provide support for creating and working with XML-defined data. The Xml
Document class, for instance, allows accessing an XML document using the Document Object Model
(DOM). This namespace also XML Schema definition language (XSD) and XPath.

•Many more namespaces are defined, providing support for file access, serializing an object’s state,
remote access to objects, and much more. The biggest task facing developers who wish to build on the .Net
Framework is learning to use the many services that the library provides. There’s no requirement to learn
everything, however, so a developer is free to focus on only those things relevant to his or her world
Boxing
• Converting a value type to a reference type object is called boxing.

• A value type is stored on stack memory and requires conversion—boxing—to an object on the heap memory before it
can be treated as an object.

• The members of the new object can be invoked on the value, e.g., converting a double to a string. Boxing
may be performed implicitly at runtime by the CLR.

• Int m = 10;

• object om = m;

• m = 20;

• Console.WriteLine (m); // m = 20

• Console.WriteLine (om); //om = 10


Unboxing
•Conversion of a reference typed object to the associated value type instance. Usually, unboxing is
performed explicitly by a cast operation.

• Int m = 10;

• object om = m;

• int n = (int) om;


CLR
• CLR is the .NET runtime environment responsible for program execution management and for
providing container services—debugging, exception management, memory management, profiling, and
security.
• The CLR is a major subsystem in the .NET Framework which implements the Common Type
System. Also this is called as Virtual Execution System (VES).

•Software built on the CLR is referred to as managed code, and the CLR provides a range of things that
support creating and running this code. The CLR also provides technologies for packaging managed code and
a runtime environment for executing managed code.

•The CLR supports the creation and execution of managed code.


CLR
CLR
• Common Language Specification (CLS)
• CLS is a subset of the Common Type System and a set of
conventions for promoting interoperability between programming
languages and the .NET Framework. CLS details conventions that must
be followed by class library authors and by programming language
designers.
• Common Type System (CTS)
• CTS is the .NET Framework specification for defining, declaring,
and managing types in .NET languages for the Common Language
Runtime (CLR). All .NET components must comply with the CTS
specification.
• MSIL (Microsoft Intermediate Language)

• It is language independent code. When you compile code that uses the .NET Framework library, we don't immediately
create operating system - specific native code.

• Instead, we compile our code into Microsoft Intermediate Language (MSIL) code.

• The MSIL code is not specific to any operating system or to any language.

• Garbage Collection (GC)

•One of the most important features of managed code is the concept of garbage collection.

•This is the .NET method of making sure that the memory used by an application is freed up completely when the
application is no longer in use.

• Prior to .NET this was mostly the responsibility of programmers, and a few simple errors in code could result in large blocks
of memory mysteriously disappearing as a result of being allocated to the wrong place in memory. That usually meant a
progressive slowdown of your computer followed by a system crash.
• Code Manager

• Code manager invokes class loader for execution.

• .NET supports two kind of coding

• 1) Managed Code

• 2) Unmanaged Code
• Managed Code

•The resource, which is with in your application domain is, managed code. The resources that are
within domain are faster.

•The code, which is developed in .NET framework, is known as managed code. This code is
directly executed by CLR with help of managed code execution. Any language that is written in .NET
Framework is managed code.

•Managed code uses CLR which in turns looks after your applications by managing memory,
handling security, allowing cross - language debugging, and so on.
Unmanaged Code
• The code, which is developed outside .NET, Framework is known as unmanaged code.

• Applications that do not run under the control of the CLR are said to be unmanaged, and certain languages such as
C++ can be used to write such applications, which, for example, access low - level functions of the operating system.

• Background compatibility with code of VB, ASP and COM are examples of unmanaged code.

• Unmanaged code can be unmanaged source code and unmanaged compile code. Unmanaged code is executed with
help of wrapper classes.

• The Common Language Runtime includes the following things to be analyzed.

• 1. Building Managed Code. - CTS

• 2. Compiling Managed Code. - MSIL

• 3. Organizing Managed Code. - Assemblies

• 4. Executing Managed Code.


Services provided by CLR
• Loading and execution of programs.

• Memory isolation for applications.

• Verification of type safety

• Compilation of IL into native executable code

• Providing metadata

• Memory Management (automatic garbage collection)

• Enforcement of Security

• Interoperability with other systems.

• Managing exceptions and errors

• Support for tasks such as debugging and profiling.


Benefits of CLR
• Interoperability with other languages

• Enhanced security

• Versioning support

• Debugging support

• Automatic garbage collection

• XML support for web‐based applications


Windows Forms
• Smart client technology for the .NET Framework
• Windows Forms (WinForms) is a UI framework for building Windows desktop
applications.
• It is a .NET wrapper over Windows user interface libraries, such as User32 and GDI+. It
also offers controls and other functionality that is unique to Windows Forms.
• Set of managed libraries to simplify application tasks such as reading and writing to the
file system.
• In Windows Forms, a form is a visual surface on which you display information to the
user.
• Enables drag-and-drop of visual controls and other similar functionality that make it easy
to build desktop applications.
• User -> Form-> Control-> Event action generated.
• Application reacts with events using code and processes the events when they occur.
• Contains variety of controls that you can add to forms: Controls that display text boxes,
buttons, drop-down, radio buttons and even web pages.
Building Managed Code: The Common Type System

•A programming language usually defines both syntax and semantics.

•When a new programming language is defined, the usual approach is to define underlying abstractions such
as key aspects of the language’s semantics.

•The CTS specifies no particular syntax or keywords, but instead defines a common set of types that can be
used with many different language syntaxes.

• Each language has its own syntax, but if that language is built on the CLR, it will use at least some of the
types defined by the CTS. The Common Type System defines core semantics but not syntax.

•Types are fundamental to any programming language. One simple but concrete way to think a type is a set
of rules for interpreting the value stored in some memory location, such as the value of a variable.

•The CTS defines reference and value types, all of which inherit from a common Object type.
• The first thing to note is that every type inherits either directly or indirectly from a type called Object.
• The second thing to note is that every type defined by the CTS is either a reference type or a value type.
• As the name suggest, an instance of a reference type always contains the value itself.
• Reference types inherit directly from Object, while all value types inherit directly from a type called ValueType, which in turn
inherits from Object.
• The types in this category include Byte, Char, signed and unsigned integers of various lengths, single- and double-precision
floating point, Decimal, Boolean, and more.
• Reference types, by contrast, are typically more complex. As shown in the figure, for instance, Class, Interface, Array, and
String are reference types.
• To understand the difference between value types and reference type we must understand how memory is allocated for
instances of each type.
• In managed code, values can have their memory allocated in one of two main ways, both managed by the CLR: on the stack
or on the heap.
• Variables allocated on the managed stack are typically created when a method is called or when a running method creates
them.
• In either case, the memory used by stack variables is automatically freed when the method in which they were created
returns.
• Variables allocated on the managed heap, however, don’t have their memory freed when the method that created them ends.
Instead, the memory used by these variables is freed via a process called garbage collection.
• Value Types

• All value types inherit from ValueType. Like Object, ValueType provides an Equals method. Value types
cannot act as a parent type for inheritance, however, so it’s not possible to say, define a new type that inherits
from Int32.

• Many of the value types are defined by the CTS. Those types are as follows:

• Byte: An 8-bit unsigned integer

• Char: A 16 – bit Unicode character.

• Int16, Int32, and Int64: 16-, 32-, and 64- bit unsigned Integers.

• Single and Double: Single-precision (32-bit) and double-precision (64-bit) floating-point numbers.
• Decimal: 96-bit decimal numbers.

• Enum: A way to name a group of values of some integer type. Enumerated types inherit from System.Enum and are used to define types whose values
have meaningful names rather than just numbers.

• Boolean: True or False

• Reference Types:

• Compared with most value types, the reference types defined by the CTS are relatively complicated. Before describing some of the more
important reference types, it’s useful to look first at a few elements, officially known as type members that are common to several types. Those elements
are as follows:

• Methods:

• Executable code that carries out some kind of operation. Methods can be overloaded, which means that a single type can define two or more
methods with the same name. To distinguish among them, each of these identical named methods must differ somehow in its parameter list. Another way
to say this is to state that each method must have a unique signature. If a method encounters an error, it can throw an exception, which provides some
indication of what has gone wrong, provides some indication of what has gone wrong.
• Fields: A value of some type.

• Events: A mechanism for communicating with other types. Each event includes methods for subscribing and unsubscribing and for sending the event to
subscribers.

• Properties: In effect, a value together with specified methods to read and/or write that value.

• Nested Types: A type is defined inside another type. A common example of this is defining a class that is nested inside another class.

• Given this basic understanding of type members, we can now look at the types themselves. Among the most important are the following:

• Class: A CTS class can have methods, events, and properties; it can maintain its state in one or more fields; and it can contain nested types. A class’s
visibility can be public, which means it’s available to any other type, or assembly, which means it’s available only to other classes in the same assembly.
Classes have one or more constructors, which are initialization methods that execute when a new instance of this class is created. A class can directly inherit
from at most one other class and can act as the direct parent for at most one inheriting child class.

• Interface: AN Interface can include methods, properties, and events. Unlike classes, interfaces do support multiple inheritance, so an interface can inherit
from one or more other interfaces simultaneously. An interface does not actually implement anything, however. Instead, it provides a way to group type
definition together; leaving the implementation to whatever type supports the interface.

• Array: An array is a group of values of the same type. Arrays can have one or more dimensions, and their upper bounds and lower bounds can be set more
or less arbitrarily. All arrays inherit from a common System.Array type.

• Delegate: A delegate is effectively a pointer to a method. All delegates inherit from a common System.Delegate type, and they are commonly used for event
handling and callbacks. Each delegate has a set of associated members called an invocation list. When the delegate is invoked, each member on this list gets
called; with each one passed the parameters that the delegate received.
Converting Value Types to Reference Types: Boxing

• There are cases when an instance of a value type needs to be treated as an instance of a reference type. For
example, suppose we would like to pass an instance of a value type as a parameter to some method, but that
parameter is defined to be a reference to a value rather than the value itself. For situations like this, a value
type instance can be converted into reference type instance through a process called Boxing.

• When a value type instance is boxed, storage is allocated on the heap, and the instance’s value is
copied into that space. A Reference to this storage is placed on the stack, as shown in the figure.
• A boxed value type instance can also be converted back to its original form, a process called unboxing.
Boxing converts a value type instance into an instance of an
analogous type
The Common Language Specification

• The CTS defines a large and fairly complex set of types.

• Not all of them make sense for all languages. Yet one of the key goals of the CLR is to allow creating code in one
language, then calling that code from another. Unless both languages support the same types in the same way, doing
this is problematic. Still, requiring every language to implement every CTS type would burden some to language
developers.

• The solution to this problem, a compromise called the Common Language Specification (CLS). The CLS defines a
subset of the CTS that a language must obey if it wishes to interoperate with other CLS-compliant languages. The
CLS defines a subset of the CTS to enable cross-language interoperability. One important thing to note about the
rules laid down by the CLS is that they apply only to externally visible aspects of a type. A language is free to do
anything it wants within its own world, but whatever it exposes to the outside world and thus potentially to other
languages it is constrained by the CLS.
• When source code written in a CLR-based language is compiled, two things are produced: instructions
expressed in Microsoft Intermediate Language (MSIL), and metadata, information about those instructions
and the data they manipulate

Compiling managed code written in any language produces


MSIL and metadata describing that MSIL.

You might also like