Top Banner
Introduction to .NET Framework
52

.Net overview|Introduction Of .net

Jan 26, 2017

Download

Career

pinky singh
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: .Net overview|Introduction Of .net

Introduction to .NET Framework

Page 2: .Net overview|Introduction Of .net

.NET – What Is It?

• Software platform• Language neutral• In other words:

.NET is not a language (Runtime and a library for writing and executing written programs in any compliant language)

Page 3: .Net overview|Introduction Of .net

What Is .NET• .Net is a new framework for developing

web-based and windows-based applications within the Microsoft environment.

• The framework offers a fundamental shift in Microsoft strategy: it moves application development from client-centric to server-centric.

Page 4: .Net overview|Introduction Of .net

.NET – What Is It?

Operating System + Hardware

.NET Framework

.NET Application

Page 5: .Net overview|Introduction Of .net

Base Class LibraryBase Class Library

Common Language SpecificationCommon Language Specification

Common Language RuntimeCommon Language Runtime

ADO.NET: Data and XMLADO.NET: Data and XML

VBVB VC++VC++ VC#VC#Visual Studio.N

ETVisual Studio.N

ET

ASP.NET: Web ServicesASP.NET: Web Servicesand Web Formsand Web Forms

JScriptJScript ……

WindowsWindowsFormsForms

Framework, Languages, And Tools

Page 6: .Net overview|Introduction Of .net

The .NET Framework.NET Framework Services

• Common Language Runtime• Windows® Forms• ASP.NET

– Web Forms– Web Services

• ADO.NET, evolution of ADO• Visual Studio.NET

Page 7: .Net overview|Introduction Of .net

Common Language Runtime (CLR)

•CLR works like a virtual machine in executing all languages. •All .NET languages must obey the rules and standards imposed by CLR. Examples:– Object declaration, creation and use– Data types,language libraries– Error and exception handling– Interactive Development Environment (IDE)

Page 8: .Net overview|Introduction Of .net

Common Language Runtime

• Development– Mixed language applications

• Common Language Specification (CLS)• Common Type System (CTS)• Standard class framework• Automatic memory management

– Consistent error handling and safer execution– Potentially multi-platform

• Deployment– Removal of registration dependency– Safety – fewer versioning problems

Page 9: .Net overview|Introduction Of .net

Common Language RuntimeMultiple Language Support

• CTS is a rich type system built into the CLR– Implements various types (int, double, etc)– And operations on those types

• CLS is a set of specifications that language and library designers need to follow– This will ensure interoperability between

languages

Page 10: .Net overview|Introduction Of .net

Compilation in .NET

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

VB.NET compiler C# compiler AppropriateCompiler

IL(IntermediateLanguage) code

CLR just-in-timeexecution

Page 11: .Net overview|Introduction Of .net

CTS and CLS are parts of .NET CLR and are responsible for type safety with in the code. Both allow cross language communication and type safety. In this article I would like to expose the relationship between these two.CTSCTS stands for Common Type System. It defines the rules which Common Language Runtime follows when declaring, using, and managing types. The common type system performs the following functions:It enables cross-language integration, type safety, and high-performance code execution.It provides an object-oriented model for implementation of many programming languages.It defines rules that every language must follow which runs under .NET framework. It ensures that objects written in different .NET Languages like C#, VB.NET, F# etc. can interact with each other.

Page 12: .Net overview|Introduction Of .net

CLSCLS stands for Common Language Specification and it is a subset of CTS. It defines a set of rules and restrictions that every language must follow which runs under .NET framework. The languages which follows these set of rules are said to be CLS Compliant. In simple words, CLS enables cross-language integration.For example, one rule is that you cannot use multiple inheritance within .NET Framework. As you know C++ supports multiple inheritance but; when you will try to use that C++ code within C#, it is not possible because C# doesn’t supports multiple inheritance. One another rule is that you cannot have members with same name with case difference only i.e. you cannot have add() and Add() methods. This easily works in C# because it is case-sensitive but when you will try to use that C# code in VB.NET, it is not possible because VB.NET is not case-sensitive.

Page 13: .Net overview|Introduction Of .net

Why CTS is Called Common Type System?

In .NET, every Data Type is internally represented by a class or structure. All the classes and structures related to Data Types are collectively known as CTS. As you know every language provides its own keywords for Data Types but internally all the languages which run under .NET framework use the classes and structures available in CTS. For example, C# has int Data Type and VB.Net has Integer Data Type. Hence a variable declared as int in C# or Integer in vb.net, finally after compilation, use the same structure Int32 from CTS. All the structures and classes available in CTS are common for all .NET Languages and purpose of these is to support language independence in .NET. Hence it is called CTS

Page 14: .Net overview|Introduction Of .net

MSIL

• It is a set of CPU independent instructions that are generated by the language compiler when the project is compiled. MSIL code is not executable but further processed by CLR/other runtime environments before it becomes executable. MSIL is contained in the assembly of the .NET application.

Page 15: .Net overview|Introduction Of .net

Intermediate Language (IL)• .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 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.

Page 16: .Net overview|Introduction Of .net

• Features: MSIL instructions map to the code that is written in .NET Language and are used for loading, storing, initializing, and calling methods on objects, as well as for arithmetic and logical operations, control flow, direct memory access, exception handling, and other operations.

CLS(Common language Specification) provides the infrastructure for MSIL.

Page 17: .Net overview|Introduction Of .net

Benefits:

• Benefits:

1)MSIL provides language interoperability as the code in any .NET language is compiled into MSIL.

2)Same performance for all the .NET Languages:

Page 18: .Net overview|Introduction Of .net

• 3)Support for different runtime environments:

CLR can understand MSIL.

Non .NET environments also support MSIL. -----------------------------------------------------------

The JIT Compiler in CLR converts the MSIL code into native machine code which is then executed by the OS

Page 19: .Net overview|Introduction Of .net

JIT

• JIT stands for just-in-time compiler. It converts the MSIL code to CPU native code as it is needed during code execution. It is called just-in-time since it converts the MSIL code to CPU native code; when it is required within code execution otherwise it will not do nothing with that MSIL code.

Page 20: .Net overview|Introduction Of .net

Different Types of JIT

• Normal JIT• This complies only those methods that are

called at runtime. These methods are compiled only first time when they are called, and then they are stored in memory cache. This memory cache is commonly called as JITTED. When the same methods are called again, the complied code from cache is used for execution.

Page 21: .Net overview|Introduction Of .net
Page 22: .Net overview|Introduction Of .net

Econo JIT

• This complies only those methods that are called at runtime and removes them from memory after execution.

Page 23: .Net overview|Introduction Of .net
Page 24: .Net overview|Introduction Of .net

Pre JIT

• This complies entire MSIL code into native code in a single compilation cycle. This is done at the time of deployment of the application.

Page 25: .Net overview|Introduction Of .net
Page 26: .Net overview|Introduction Of .net

Native Code

• Before you can run Microsoft intermediate language (MSIL), it must be converted by a .NET Framework just-in-time (JIT) compiler to native code, which is CPU-specific code that runs on the same computer architecture as the JIT compiler.

Page 27: .Net overview|Introduction Of .net

• Because the common language runtime supplies a JIT compiler for each supported CPU architecture, developers can write a set of MSIL that can be JIT-compiled and run on computers with different architectures. However, your managed code will run only on a specific operating system if it calls platform-specific native APIs, or a platform-specific class library.

Page 28: .Net overview|Introduction Of .net

• Native code is computer programming (code) that is compiled to run with a particular processor (such as an Intel x86-class processor) and its set of instructions. If the same program is run on a computer with a different processor, software can be provided so that the computer emulates the original processor

Page 29: .Net overview|Introduction Of .net

Interoperating Between Native Code and Managed Code

• Code that runs under the control of the common language runtime (CLR) is known as managed code. Code that does not run under the CLR is known as native code. The Windows API is one example of native code

Page 30: .Net overview|Introduction Of .net

Languages

• Languages provided by MS– VB, C++, C#, J#, JScript

• Third-parties are building– APL, COBOL, Pascal, Eiffel, Haskell, ML,

Oberon, Perl, Python, Scheme, Smalltalk…

Page 31: .Net overview|Introduction Of .net

Windows Forms• Framework for Building Rich Clients

– RAD (Rapid Application Development)– Rich set of controls– Data aware– ActiveX® Support– Licensing– Accessibility– Printing support– Unicode support– UI inheritance

Page 32: .Net overview|Introduction Of .net

ASP.NET•ASP.NET,the platform services that allow to program Web Applications and Web Services in any .NET language

•ASP.NET Uses .NET languages to generate HTML pages. HTML page is targeted to the capabilities of the requesting Browser

•ASP.NET “Program” is compiled into a .NET class and cached the first time it is called. All subsequent calls use the cached version.

Page 33: .Net overview|Introduction Of .net

ASP.NET

• Logical Evolution of ASP– Supports multiple languages– Improved performance– Control-based, event-driven execution model– More productive– Cleanly encapsulated functionality

Page 34: .Net overview|Introduction Of .net

ASP.NET Web Forms• Allows clean cut code

– Code-behind Web Forms• Easier for tools to generate• Code within is compiled then executed • Improved handling of state information• Support for ASP.NET server controls

– Data validation– Data bound grids

Page 35: .Net overview|Introduction Of .net

ASP.NET Web Services

• A technical definition– “A programmable application component accessible

via standard Web protocols”

Page 36: .Net overview|Introduction Of .net

Web Services

• It is just an application…• …that exposes its features and capabilities

over the network…• …using XML…• …to allow for the creation of powerful new

applications that are more than the sum of their parts…

Page 37: .Net overview|Introduction Of .net

ADO.NET(Data and XML)

• New objects (e.g., DataSets)• Separates connected / disconnected issues• Language neutral data access• Uses same types as CLR• Great support for XML

Page 38: .Net overview|Introduction Of .net

Visual Studio.NET

• Development tool that contains a rich set of productivity and debugging features

Page 39: .Net overview|Introduction Of .net

.NET – Hierarchy, Another View

CLR

CLR

Page 40: .Net overview|Introduction Of .net

Summary

• The .NET Framework– Dramatically simplifies development and deployment– Provides robust and secure execution environment– Supports multiple programming languages

Page 41: .Net overview|Introduction Of .net

Comparison between J2EE and .NET

Page 42: .Net overview|Introduction Of .net

Comparison between J2EE and .NET Architectures

Page 43: .Net overview|Introduction Of .net

J2EE and .NETExecution Engine J2EE

Java source code compiles into machine-independent byte codeRuntime Environment : JVM

.NETAny compliant language compiles into MSILRuntime environment : CLR

Both JVM and CLR ,support services, such as code verification, memory management via garbage collection, and code security

Page 44: .Net overview|Introduction Of .net

J2EE and .NETCross Platform Portability

J2EEPlatform Independent JDK should exist on target machine

.NETSupports Windows platformCLR should exist on target machine

Can support other platforms provided it has its own JIT complier

Page 45: .Net overview|Introduction Of .net

J2EE and .NET

Language Support

J2EETied to Java Supports other languages via interface technology

.NETLanguage independentSupports any language if mapping exists from that

language to IL

Page 46: .Net overview|Introduction Of .net

J2EE and .NET

Tools Support J2EE

Can employ any number of toolsPro :Developer has a great deal of choiceCon :Difficulty in choosing a right tool for a given

job

.NETVisual Studio.NET, single IDE for building an

application

Page 47: .Net overview|Introduction Of .net

The varibles in C#, are categorized into the following types:

• Value types• Reference types• Pointer types• Value Type• Value type variables can be assigned a value

directly. They are derived from the class

Page 48: .Net overview|Introduction Of .net

• System.ValueType.• The value types directly contain data. Some

examples are int, char, and float, which stores numbers, alphabets, and floating point numbers, respectively. When you declare an int type, the system allocates memory to store the value

Page 49: .Net overview|Introduction Of .net

• Reference Type• The reference types do not contain the actual data

stored in a variable, but they contain a reference to the variables.

• In other words, they refer to a memory location. Using multiple variables, the reference types can refer to a memory location. If the data in the memory location is changed by one of the variables, the other variable automatically reflects this change in value. Example of built-in reference types are: object, dynamic, and string.

Page 50: .Net overview|Introduction Of .net

• Dynamic Type• You can store any type of value in the dynamic

data type variable. Type checking for these types of variables takes place at run-time.

• Syntax for declaring a dynamic type is:• dynamic <variable_name> = value; For example,• dynamic d = 20;

Page 51: .Net overview|Introduction Of .net

• String Type• The String Type allows you to assign any string

values to a variable. The string type is an alias for the System.String class. It is derived from object type. The value for a string type can be assigned using string literals in two forms: quoted and @quoted.

• For example,• String str = "Tutorials Point";

Page 52: .Net overview|Introduction Of .net

• Pointer Type• Pointer type variables store the memory

address of another type. Pointers in C# have the same capabilities as the pointers in C or C++.

• Syntax for declaring a pointer type is:• type* identifier; For example,• char* cptr; int* iptr;