37
Evolution of .NET •Around 1995, java was becoming popular because of its platform-independent approach and sun’s policy to distribute it free. • Later in 2002, Sun released the enterprise edition of java i.e J2EE that is a programming platform under java platform to develop and execute distributed multitier architecture java application. •As a result microsoft was loosing its market . •Thus, to capture the market Microsoft started a project was called Next Generation Windows Services (NGWS). It took more than three years to develop the product and the result was what we know now as .NET. •.NET Framework 1.0 released on 13 February 2002, is the first release of the .NET Framework. •This version of the .NET Framework is also a part of the first released of Visual Studio .NET which is know as Visual Studio .NET 2002. •Later its second release of known as Visual Studio .NET 2003.

Dotnet framework

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Dotnet framework

Evolution of .NET•Around 1995, java was becoming popular because of its platform-independent approach and sun’s policy to distribute it free.• Later in 2002, Sun released the enterprise edition of java i.e J2EE that is a programming platform under java platform to develop and execute distributed multitier architecture java application. •As a result microsoft was loosing its market .•Thus, to capture the market Microsoft started a project was called Next Generation Windows Services (NGWS). It took more than three years to develop the product and the result was what we know now as .NET.•.NET Framework 1.0 released on 13 February 2002, is the first release of the .NET Framework.•This version of the .NET Framework is also a part of the first released of Visual Studio .NET which is know as Visual Studio .NET 2002.•Later its second release of known as Visual Studio .NET 2003.•Then Visual Studio .NET 2005, 2008, 2010.

Page 2: Dotnet framework

Comparison of J2EE and .NETKey Features .NET J2EE

Type of technology .NET is a product J2EE is a standard.

Operating System support

One operating System Multiple Operating Systems.

Programming Language.

It supports Programming Language like VB.NET, C#, J#, and so on.

It supports only a single programming language, java

Vendor Support Supported by single vendor ( Microsoft)

It is supported by multiple vendors

Interpreter During the first compilation process, the source code is compiled to IL which is machine independent and during the second process the IL is executed using JIT compiler and CLR transforms it into machine code. Thus any code in .NET is compiled twice.

Java code is compiled to bytecode by JRE and is interpreted or compiled to machine code.

Dynamic web pages In .Net it is ASP.NET In J2EE it’s JSP.

Graphical user Interface

Microsoft Visual Studio IDE. No other IDE support .NET.

Many Java IDE’s and tools

Database ADO.NET JDBC

Page 3: Dotnet framework

Objective of .Net Framework

• To provide object oriented environment to develop application.

• To provide a code execution environment that provides safety of code execution.

• It simplifies deployment and versioning.• It eliminates the issues faced by scripted

environment with respect to performance.• To provide a common programming model

where the choice of programming langu. becomes a matter of choice.

Page 4: Dotnet framework

Architecture of Microsoft .NET• .Net framework is made up of two

components – Common Language Runtime (CLR) and the .NET Framework Class Library (FCL).

• The CLR is basis of .Net Framework and provides various services that application can use.

• The runtime suppose to be an agent that manages code at execution time, provides core services, such as memory management and remoting.

Page 5: Dotnet framework

• It also encourage security, and robustness by implementing safety and other type of code accuracy.

• Since code management is a basic principle of the runtime, code that target runtime is known as managed code and the code that does not target the runtime is known as unmanaged code.

• The following diagram shows the relationship of common language runtime and class library to your application and to overall system. (.NET Framework architecture)

Page 6: Dotnet framework

VBVB C++ C# Jscript ----

Common Language Specification (CLS)Common Language Specification (CLS)

ADO.NET and XML

Web Application Windows Application

ADO.NET and XML

Base Class Library

Common Language Runtime (CLR)

Operating System

Page 7: Dotnet framework

• You can see Operating System at the base. It can be any Microsoft windows platform that support Visual Studio .NET.

• CLR provides its services to application by providing a standard set of library classes called as Class Library.

• The other development platform and applications are built on top of base Class Library.

• Language Compliers that need to generate code for CLR must bound to a common set of specifications that are establish by Common Language Specification (CLS)

Page 8: Dotnet framework

Common Language Runtime

• CLR is the platform on which applications are hosted and executed.

• It is used to manage memory, thread execution, code execution, code safety, verification, compilation, and other system services.

• Since the runtime manages the execution of your code, code that works on the CLR is called managed code.

• The CLR also supports a set of services that the application can use to access various resources like arrays, collections, operating System folders etc.

Page 9: Dotnet framework

• Interoperability between managed and unmanaged code enables developers to continue to use COM components and DLLs.

• The managed environment of the runtime eliminates many common software issues. For example the runtime automatically releases the object when they are no longer being used.

• This automatic memory management resolves the memory leaks and invalid memory references.

• Since runtime supports code access security and code robustness, it implements a strict type and code verification infrastructure called Common Type System (CTS). It ensures that all managed code is self-describing.

Page 10: Dotnet framework

• The programmer can write application in the development language of their choice such as C#, VB, ASP.NET etc.

• Managed code is never interpreted. A feature called Just-in-time compiling enables to run the managed code in the native machine language of the system on which it is executing.

Page 11: Dotnet framework

Advantages of CLR

• Enhance performance and productivity.• The power of using components develop in other

languages.• Using CLR, you can experience extensible type provided

by class Library.• Access to new features and characteristics of language

like inheritance, interface and overloading for object- oriented Programming.

• It allows to create multithreaded, Scalable application.• Structured exception handling and custom attributes are

supported by the CLR.

Page 12: Dotnet framework

Compiler and Loader:CLR uses JIT and compiles the IL code to machine code and then

executes . CLR also determines depending on platform what is optimized way of running the IL code.

Code verification and optimization:This ensures proper code execution and type safety while the code runs.

It prevents the source code to perform illegal operation such as accessing invalid memory location etc.

Memory management and garbage collection:CLR automatically manages memory thus eliminating memory leaks.When object are not referred GC automatically releases those.

Code Access Security:CAS grants rights to the program depending on security

configuration of the machine. Example the program has rights to edit or create a new file but the security configuration of machine does not allow the program to delete a file.

CAS will take care that the code runs under the environment of the machine security configuration

Page 13: Dotnet framework

Type Safety and Security

• Type-safe code accesses only the memory locations it is authorized to access .

• For example, type-safe code cannot read values from another object's private fields. It accesses types only in well-defined, allowable ways.

• This process is skipped if the code has permission to bypass verification

Page 14: Dotnet framework

• The code whose execution is managed by CLR is known as Managed code.

• It refers to a contract of cooperation between natively executing code and runtime.

• This contract determines that at any point of execution, the runtime may stop an executing CPU and retrieve information specific to the current CPU instruction address.

• Managed code are compiled to IL not to machine code that could run directly on your computer.

• The IL is kept in a file called an assembly along with metadata to describe all of the entry points, classes, methods, and attributes of the code that you have created.

Managed code

Page 15: Dotnet framework

• CLR first loads and verifies the assembly to approve IL. While assembly runs, the runtime continues to provide services such as security, memory management, threading and so on.

• Where as unmanaged code compiled directly to the m/c code and runs to the m/c where you compiled it.

• It does not get services like security or memory management from an invisible runtime.

• Most recent unmanaged application get operating system services through COM calls.

Page 16: Dotnet framework

Execution Process• The managed execution process includes the following steps:

– Choosing a compiler– Compiling your code to MSIL.– Compile MSIL to native code.– Execute your code.

Page 17: Dotnet framework

• Choosing a compiler:– You can choose one or more language compiler targeting the

runtime such as VB,C#, Visual C++.

• Compiling your code to MSIL:– When your compile source code into MSIL , it generated

metadata. MSIL is a CPU independent set of instructions that can be efficiently changed to native code.

– The instruction for loading, storing, initializing, arithmetic and logical operations , Control flow, direct memory access, exception handling, calling methods on object and so many other operations are included in MSIL.

– At the time of creating MSIL, the compiler also generates the metadata that describes the types, Reference or value type, in your code along with each type definition, the signature of each type’s members, members referenced by your code, and other data that the runtime uses at execution time.

– Metadata are basically information about the compiled classes.– The MSIL and metadata are contained in a portable executable

file, which is standard format for processor –specific execution.

Page 18: Dotnet framework

• Compiling MSIL to Native code:– While executing your application JIT translate the MSIL into

native code. When this compilation is performed, the code must be passed through a verification process that examines to check whether the code is type safe or not. It means that it is known to access the authorized memory location.

– JIT compilation allows the fact that some code might never get called during execution. Instead of using time and memory to convert all IL to native code, it converts the IL as needed during the execution and stores the resulting native code so that it is accessible for subsequent call.

– The runtime also supports another way of compilation known as install-time code generation. It converts all the MSIL into native code in single shot by taking larger unit of code at a time. The entire assembly is converted into native code at the installation time only.

Page 19: Dotnet framework

• Executing your code:– The method must be compiled to processor

specific code before running.– Each method for which MSIL is there is JIT

compiled, when it called for first time and then run.

– Next time when the method is run, the existing JIT compiled native code is run

Page 20: Dotnet framework

Common Type System• It provides certain guidelines for declaring,

using, managing type at runtime.• It is also an integral part of runtime for

supporting cross-language communication• Following are the functions performed by CTS

– It helps in cross-language communication, Type Safety, high performance execution.

– It supports object- oriented model for implementation of different programming language.

– It specifies the guidelines for different language to follow and ensuring interaction between object of different language.

Page 21: Dotnet framework

Classification of Types

• CTS is classified into two general catagories– Value Type:

• Value type contains its data directly and their objects are allocated on stack . Value type can be built-in, user-defined, enumeration.

– Reference Type:• It contains data’s memory address and allocated

on heap. They can be pointer type, self-describing type or interactive type.

Page 22: Dotnet framework
Page 23: Dotnet framework

Meta Data

• A metadata describes a program in the form of binary information, which is stored in a CLR portable Executable File or in memory.

• When compilation of the code take place, the metadata is inserted into one part of the file, while the code is converted into MSIL and inserted into the other part of the file.

• Every type and member is described inside the metadata.

• When code is in run mode, the CLR loads the metadata into memory and find information about the code’s classes and members and so on.

Page 24: Dotnet framework

The Metadata includes following information

• It contains assembly information like its identity, name, version, culture, public key, the types, other references assembly, and security permission.

• It contains information about types, like name, visibility, base class, and interface used, and members( methods, field, properties, events).

• It maintains attribute information which modifies types and members.

• The metadata is stored along with the code.

Page 25: Dotnet framework

Assembly• Assemblies are packed into units containing programs and

libraries.• An Assembly contains self-describing binary which can be

either Dynamic Link Library (DLL) or Executable (EXE).• It also contains a collection of types, such as classes,

interface, structure and so on.• A single assembly can contain multiple files or single file can

contain multiple assembly.• Assembly contains the code which the CLR executes.• Assembly can be of two types-static and dynamic .• Static assembly include interface, classes and resources like

bitmap, JPEG files and so on.• These assemblies are stored in PE files on disk.• Using .NET framework you can create dynamic assemblies,

which run directly from the memory and are not stored on disk before execution.

• But after they have been executed, you can save them on the disk.

Page 26: Dotnet framework

Assembly Contents• A static assembly consist of the following 4

elements.– Manifest– Type metadata– MSIL code that implements the type– Set of resources

Group these elements can be done in various way. You can group all the elements in a single physical file or all the elements of assembly can be stored in various files.

Page 27: Dotnet framework

Manifest• Every Assembly contains data that describes how the elements

within that assembly are related to each other.• The manifest contains the assembly metadata needed for

providing assembly’s version, security identity.• The manifest can be stored in a PE file within MSIL or in Standalone

file that contains only manifest information.• The following information stored in assembly manifest

– Assembly name– Version number– List of Files in Assembly– Information on referenced assembly

• It contain the list of other assembly that are referenced by the assembly – Type reference information

• Information used by runtime to map a type reference that contains its declaration and implementation

– Strong name information• It contains Public key from the publisher if the assembly has given strong

name.– Culture

• It provides information about language the assembly supports.

Page 28: Dotnet framework

Global Assembly Cache• It is the Central place for registering assemblies, which

can be later shared by different applications on the computer.

• One thing to note is that you should make the assemblies sharable by registering them in the GAC only when needed. Otherwise keep the assembly private.

• It is not mandatory to install the assemblies in GAC in order to make them accessible to the COM or unmanaged code.

• You can deploy an assembly in the GAC using following way– Use of installer which is designed to work with GAC.– Use of GAC tool know as Gacutil.exe – Use windows explorer for dragging assemblies into cache.

Page 29: Dotnet framework

Strong Name Assemblies• A strong name contains the assembly’s identity, which is

nothing but information about its name, version number, culture information, Public key and digital signature.

• Strong name can be provided to an assembly using Microsoft Visual Studio .NET.

• By providing strong name to the assembly you can ensure that an assembly is globally unique.

• Strong name fulfill following requirements:– Strong name provides uniqueness.– Strong name ensures that a version of assembly

comes from the same publisher that created the version of the application.

– Strong names facilitate integrity check, which ensures that the contents of the assembly have not been changed since it was last built.

Page 30: Dotnet framework

Private and Shared Assembly• When an assembly is used by a single application then it

is called as Private assembly.• For example you have created a DLL which contains

information about your business logic and it can be used by your client application not by any other application.

• So in order to run the application your DLL must be included in the same folder in which client application is installed . This makes the assembly private to your application.

• Now suppose the DLL, which you have created needs to be reused in different application.

• You can do it by placing the DLL in GAC instead of each client application having its own copy of DLL.

• Assembly like this is called as shared Assembly.

Page 31: Dotnet framework

Application Domain• CLR creates an application domain and

ensure that the crashing of an application domain does not affect the functioning of another application domain.

• Typically, we use process boundaries to isolate application running on the same computer.

• Each application we create is loaded into a separate process. The applications are separated from each other because memory addresses are process-relative.

Page 32: Dotnet framework

Framework Class Library (FCL)• The FCL is made up of a hierarchy of namespace that

expose classes, structures, interface, enumeration and delegates that gives you access to these resources.

• The namespace is logically defined by its functionality. For e.g System.Data namespace contains all the functionality available for accessing database.

• This namespace is further broken down into System.Data.Olebd which expose specific functionality for accessing OLEDB data sources.

• It is approximately 20,000 classes in FCL, all logically grouped in a hierarchical manner.

• FCL is huge library of reusable types, it is object-oriented library , you can use it like any other library, you can also extend the FCL towards your application needs and then write your application code

Page 33: Dotnet framework

Features of .NET• 64-bit platform support:

– Now a days there is great demand for 64 bit computers, as they enable the creation of application that can run fast and take advantage of more memory than is available to 32 bit application.

– 64-bit application enables user to build managed code libraries. It supports 32-bit application to run on 64-bit

• Access Control List Support:– .net developer can now use ACL feature to

grant or revoke the permission to access a resources on a computer

Page 34: Dotnet framework

• Authenticated Streams:– Applications can employ two new classes to

authenticate and to provide secure information transmitted between a client and server. They are NegotiateStream and SslStream.

– These authenticated stream classes supports mutual authentication, data encryption, and data signing.

– The NegotiateStream class uses the Negotiate security protocol for authentication.

– Using NegotiateStream class you can do following:• Request Server authentication• Send the client’s certificate to the server• Encrypt or sign data before transmitting.

– SslStream class uses secure socket layer (SSL) security protocol for authentication.

Page 35: Dotnet framework

• COM Interop Services Enhancement:– To support interoperability with COM improvements has been

made to classes and tools.

• Console Class Addition:– Console class represent the standard input, output, and error

streams for console applications. Console class contains methods that read individual character or entire lines from the console.

• Data Protection API:– It includes the ability to encrypt password and connection string

on the server.– You can also encrypt block of memory on the computers running

windows server 2003 or later operating System.

• Distributed Computing:– In the System.Net namespace, the support is added to FTP

client requests, caching of HTTP resources, automatic proxy discovery and obtaining network traffic and statistical information.

Page 36: Dotnet framework

• Generics and Generic Collection:– Generics allows you to create flexible and reusable

code. These are language feature, which act as templates to allow classes, structure, interface, methods, delegates to be declared with generic type parameter rather than specific types. Later when generic is used, it defines the actual types.

– The generic classes and methods are provided within several namespace like System.Namespace and System.Collections.Generic.

– Generics are supported basically in three languages visual basic, C#, and C++.

• Globalization:– Globalization refers to the process with which an

application or software will be designed and developed to make it run across all platforms and all sites with minimum or no modification to application.

Page 37: Dotnet framework

• .NET Framework Remoting– Remote means any object which executes outside the

application domain.– .Net framework remoting supports IPV6 address.– It enables developers to write scalable distributed application.– .Net remoting is an architecture , which enables communication

between different application domains or processes using different transportation protocol, serialization formats, object lifetime schemes and mode of object creation.

• ClickOnce Deployment:– Click Once Deployment permits you to deploy self-updating

windows application that can be installed and run as easily as web Application.

– It overcomes following three issues in deployment• Difficulties in updating Application

– To update the application user have to reinstall the entire application, This feature update the application automatically.

• Impact to the user’s Computer:– While publishing your application using click once deployment, each

application is self- contained and cannot interfere with other application.• Security Permission:

– It allows non-administrative users to install and grant only those code access security permission necessary for the application.