48
1

Net Framework

Embed Size (px)

DESCRIPTION

.Net Framework

Citation preview

Page 1: Net Framework

1

Page 2: Net Framework

2

Page 3: Net Framework

If you want to create a project and if different modules are written in different languages using different technologies even, combining them together is a tough job, since every technology and every language is different from each other. Their data types are different, memory management, execution, compilation and even application life cycle are different.

Consider, one module is written in C++ and another in C#. The memory space required for different data types are different in those two languages, the memory management technique related to object destruction is different in those technologies (C# is part of .NET technology, remember).

So, in this case combining these two modules will be a complicated job.

3

Page 4: Net Framework

4

Page 5: Net Framework

COM: Component Object Model technology was released by Microsoft in 1993. This is quite similar to .NET technology. The essence of COM is a language-neutral way of implementing objects that can be used in environments different from the one in which they were created, even across machine boundaries. VB 6.0, VC++ 6.0 etc languages are used to create simple to enterprise level applications. ADO (ActiveX Data Object, DAO (Data Access Object) and RDO (Remote Data Access) are some of its data access technology which are used to access data from different types of data bases. COM used ASP (Active Sever Pages) technology to create web applications, containing one or more than one web pages.

DLL(Dynamic Link Library): Whenever you create an application and compile it, then an output file is generated. If you are creating an application containing a class or more than one class, but none of the classes having Main function, then the output file generated as a result of the compilation will have an extension .dll (Dynamic Link Library). It is a reusable piece of application that can’t run directly (since, the application does not have anyMain function in any of the classes in it) but used by other applications.

EXE (Executable): It is also an application output file extension. But it is generated as result of compilation of application, which has main method in any one of its containing classes. This application can be run directly, since it contains Main method.

Necessity of .NET Technology:

Microsoft had a technology known as Windows DNA to create scalable distributed, enterprise-ready web applications.

But, Microsoft has come up with a new .NET technology because….

1. Integration: Problems regarding integration of different modules developed using different technologies.

2. Cross-language interoperability: Cross-language interoperability was also limited. For example, if classes had already been developed in VC++, then it was not possible to develop new classes in VB by extending from those classes of VC++.

3. Registration of COM components: Registration of COM components was another headache. COM components had to be registered on the target machine, before any application in that target machine would like to use them.

4. Unloading COM components: COM objects require special logic for cleaning up the objects created using COM technology languages, like VC++, VB 6.0 etc.

5. DLL Hell: If any application which is using COM components, is installed in any machine, the registry of that machine is updated with the information of those COM components used by that application. So, if one application, using set of COM components, is installed on a machine and then another application with similar set of COM components with just different version number is also installed on that machine, then there is a chance that the previous DLLs could be overwritten by the new ones and the first application ends up referring wrong DLLs. This caused a major problem when an application was referring a particular version of a DLL.

5

Page 6: Net Framework

6

Page 7: Net Framework

There is a simple vision of .NET technology and that is you can develop any type of application, be it desktop-based application, web-based application, service application using any .NET compatible language (such as, C#.NET, VB.NET, VC++.NET) in a machine using any operating system (Windows, Linux etc.), which using Internet, can connect to any type of Web Service or any other type of application located in other system, too as well as access data from any type of source of data, be it an XML file, Excel file or SQL sever database, Oracle database, MySql database etc.

7

Page 8: Net Framework

The advantages are many…..

1. Simplify the process of developing, testing, executing ,deploying and maintenance of any application.

2. Provides global acceptance for .NET applications by sticking to the web standards, such as using XML to transfer data, using SOAP (Simple Object Access Protocol) or using HTTP (Hyper Text Transfer Protocol) while developing those applications.

3. Provide a common platform and framework to create components, where component created using one language can be used by components create using other .NET-compatible languages.

4. .NET gives you the facility to create application using many languages such C#, VB.NET, VC++.NET etc. using the same RAD (Rapid Development Environment) tool Visual Studio.

3. The application code created using .NET is portable and executable in any target machine.

5. The application code written in any .NET-compatible language follows a common standard, CLS (Common Language Specification)

6. Provides interoperability amongst modules or components developed using different languages as well as different technologies.

8

Page 9: Net Framework

9

Page 10: Net Framework

Enterprise Servers:

1. MS SQL Server 2000: The complete database and analysis solution.

2. Microsoft Application Center 2000:The deployment and management tool for

high availability Web applications built on

Windows 2000.

3. Microsoft BizTalk Server 2000: BizTalk Messaging Services provides the

ability to send business documents in a secure and reliable manner. An

example of such a document could be a purchase order sent to a supplier, or a

request for a price quote on the same product sent to multiple

suppliers in order to select the lowest bidder

4. Microsoft Commerce Server 2000: The solution for quickly building an

effective online business

5. Microsoft Exchange Server 2000: The reliable, easy to manage messaging

and collaboration solution for bringing

users and knowledge together Can be used as a Mail Server Contains powerful

and in-built Workflow capabilities

10

Page 11: Net Framework

Web Service: It is reusable application (component) which processes any request from applications (client) developed using same or othertechnologies and in return delivers output (data) to those applications across system boundaries in platform-independent, neutral manner (preferably using XML to describe data and Simple Object Access Protocol along with HTTP).

Consider you are trying to create a web site like makemytrip.com which will help any user to enquiry and book airlines ticket. You developed and designed a web page nicely which will retrieve flight details and ticket prices from databases of different airlines organization, such as Jet Airways, Air Decan, Kingfisher etc., based user input (such, date and time of flight, no of passengers, one way or round trip etc.). But if you try to access flight related data from different databases and return a web page filled with that data to the user, then as a developer you have to write a bulk amount of complex code. Even when an user wants to book ticket after selecting a flight, then again your web site should have a web page regarding collecting payment and processing that. So, it takes lots of time, coding and complex logic for you to develop that web site. Instead, you can use a web service, which is an application that is deployed on the same or different machine. It will be having a class with one or few methods, who will be responsible to access flight related data from different databases based on the user input passed to it by any web site by calling those methods and will return that data to the web site. So, complex business logic or data access logic will be present inside the web service class code. Web site developer’s job will be to connect to the application (web service) present on other machine, call the methods of the web service class, pass some user input to the methods and in turn web service class method will return the desired data to the web site.

Since, the web site and the web service may be built using different languages and technologies, hence web services do return data by converting the return data in XML (Extensible Markup language). XML is a language which describes data, unlike HTML (Hyper Text Markup Language) which formats data. Any web site, built using any language and technology, can understand the return data in XML format (since it is globally accepted language to describe data and follows a common standard set by W3C (world wide web consortium)).

Thus, web services are kind of distributed application, which distributes data in platform, technology and language neutral manner to different applications and contains complex business logic(and sometimes data access logic). It exposes the methods to the outside world using different techniques, but do not expose the complex logic inside them. They are mainly used in 3-tier architecture, n-tier architecture.

Windows Service: Microsoft Windows services, formerly known as NT services, enable you to create long-running executable applications that run in their own Windows sessions. When deployed, these applications (services) can be automatically started when the computer boots, can be paused and restarted, and do not show any user interface. These features make services ideal for use on a server or whenever you need long-running functionality that does not interfere with other users who are working on the same computer.

To see different windows services running in your machine, you go to Start>Control Panel>Administrative Tools>Services.

Such as, Windows O/S uses a windows service to notify user about upgradation of different Windows components when the system is connected to the internet.

Third-Party Services: Different third-party vendor services can be used by .NET applications, too, such as, services created by IBM or many third party-services can be found in Google also.

11

Page 12: Net Framework

12

Page 13: Net Framework

13

Page 14: Net Framework

Before .NET framework component discussion, we need to understand some terminologies related to and execution cycle of .NET applications.

14

Page 15: Net Framework

Layered Architecture of .NET Framework:

1. You can create .NET application in any .NET compatible language. (Top layer)

2. You can built any type of .NET application, such as, web applications using ASP.NET (Active Server Pages .NET) technology, desktop-based application (Windows Forms Application), Web Services, which uses XML (Extensible Markup Language) to transfer data to any client application.

3. Any of those applications can access and manipulate data from any type database. The technology used for this purpose is known as ADO.NET (ActiveX Data Access .NET) technology.

4. Whenever you build any type of application, you take help from .NET Framework base class library, because it contains rich set ofdynamic link libraries containing different in-built data types.

5. Ultimately after developing and compiling the applications, you need CLR (Common Language Runtime), the runtime environment for .NET applications, to run the applications. This CLR is responsible for executing the application, memory management as well as deallocating memory space for any object from memory.

6. While running, these applications may use some of the system dynamic link libraries (Win32 dlls), services from other technologies (such, COM+ or Component Object Model+ transaction services for creating application which will be used for online transaction of money from one account to another; IIS as web serve to receive and process request for web pages from client machine)

15

Page 16: Net Framework

NET Applications involves two-step execution process.

1. Source code compiled to IL( Intermediate Language) code by the language-specific compiler.

2. The IL (Intermediate Language) code is converted into binary code or machine level code

16

Page 17: Net Framework

17

So, in these two slides (slide no 16 and 17) you get the idea about how a .NET application is compiled and executed.

Note that when a source code is compiled, not only that code gets converted into Intermediate Language code (IL code) or MSIL (Microsoft Intermediate Language), but also an assembly is generated (assembly is nothing but an output file either with an extension with .exe or .dll, generated as a result of application compilation) and IL code is one part of that assembly. In the next slide you get a better picture of assembly.

Also, noticeable that there are two compilers involved in this execution process, in the very first step, language specific compiler generates the assembly (with IL code in it) and in the next step JIT (Just-In-Time) compiler of CLR (Common Language Runtime) is used to convert the IL code of the assembly to native code first and that native code is executed.

Explanation on the CLR has been provided in the latter slides.

Page 18: Net Framework

As you can see from .NET application execution cycle, the source code is compiled into IL code and that IL code is part of an assembly. Assembly is nothing but the output file, with extension .exe or .dll, generated as a result of compilation of source code.

Afterwards, this whole assembly (.exe/.dll) is loaded into the runtime (CLR) and there the JIT compiler converts this IL code out of the whole assembly into a native code.

18

Page 19: Net Framework

In the next slide the description about all the assembly component has been given.

An assembly is nothing but an output file generated as a result of compilation of a .NET application. That output file is a type of Portable Executable file, since this output file can be taken in any machine (portable) and can be run on that machine (executable), provided .NET framework is installed in the target machine.

There are two types of Portable Executable(PE) file.

PE32 file: Portable-Executable file for 32-bit operating system.

PE64 file: Portable-Executable file for 64-bit operating system.

Any assembly is a standard PE32 or PE64 file.

19

Page 20: Net Framework

Public key: it is a cryptographic key used for Hashing technique (one of the security feature to secure any data). It is 64/128b bit alphanumeric key. It can be generated by SN.EXE tool in .NET. It is used in .NET framework to secure an assembly as well as to convert a private assembly into a shared assembly (will be discussed in next few slides).

Version No: Such as, 1.0.0.0 (Major-1, Minor-0, Build-0 and Revision-0 no)

20

Page 21: Net Framework

Type Metadata includes….

1. All data types that you have used directly or indirectly (such as, you have inherited a class from another class which is not part of that application code, but part of some other assembly)

2. All members of every data types, such as methods, properties etc.

3. User strings (such as, you have used WriteLine method of Console class to print some string)

4. Also. small amount of information about the assembly ,too.

21

Page 22: Net Framework

22

Page 23: Net Framework

23

Page 24: Net Framework

24

Page 25: Net Framework

25

Page 26: Net Framework

26

Page 27: Net Framework

1. Since, every source code written into different .NET compatible language is converted into IL code first, hence you can integrate module written in different languages so easily. Because all the source codes have been converted into IL code, so basically the integration is taking place between IL codes. It provides respite to the problem of interoperability and helps in cross-language integration.

2. Assembly contains information about everything, starting from the application details in Assembly Manifest (version number, name of the application, extension of the module, description of assemblies that this assembly is dependent on), detailed information about all the data types declared in the source code till resources and which .NET Framework version was used to create this assembly. That is why this output file or the assembly is a self describing unit.

3. This assembly can be easily deployed in any target machine in order to run.

4. Creating different version (1.0.0.0 , 2.0.0.0 version etc.) of the same assembly is very easy and those different version of the same assembly can be present in the system at the same time (at a common location in the system known as Global Assembly Cache or GAC –C:\windows\assembly folder in the system)

5. The objects that are created in the application are allocated memory space in a logical segment of the process memory space for the application to run, known as Heap. Object’s memory space allocation is the responsibility of the CLR. Similarly, CLR uses GC or Garbage Collector to de-allocate memory space for the objects in the heap (destroying the objects). So, developer need not to destroy object and de-allocate memory space for any object.

6. .NET provides a very flexible and easy technique to debug application to find out any logical error.

27

Page 28: Net Framework

If you want to access data from SQL server databases, then all the in-built classes which are required to get connected (SqlConnection class) to the SQL Server database, passing query to SQL server database (SqlCommand) etc., are placed under a logical group, known System.Data.SqlClient in this case. This System.Data.SqlClient is a Namespace. Similarly the in-built classes required to access data from Oracle database (Such as, OracleClient, OracleCommand) are placed under the same logical group name System.Data.OracleClient. Once again common in-built classes related to data access from any kind of database are placed under a namespace, System.Data.

So, all the in-built data types are organized into Namespaces and hierarchically. (System.Data, System.Data.SqlClient,System.Data.OracleClient like this).

Actually namespace is nothing but the name of the dynamic link library (which contains reusable piece of code) application in which those in-built data types are defined or written.

28

Page 29: Net Framework

29

Page 30: Net Framework

30

Page 31: Net Framework

31

Page 32: Net Framework

32

Page 33: Net Framework

33

Page 34: Net Framework

34

Page 35: Net Framework

35

Page 36: Net Framework

36

Page 37: Net Framework

37

The .NET Framework 3.0 requires the .NET Framework 2.0 to be installed on the computer. If a user installs the .NET Framework3.0 on a computer that does not have the .NET Framework 2.0 installed, the .NET Framework 2.0 is installed automatically.

The following technologies are introduced in the .NET Framework 3.0:

Windows Presentation Foundation (WPF).

Windows Communications Foundation (WCF).

Windows Workflow Foundation (WF).

Page 38: Net Framework

Notes:

Do you or any of your customers suffer from…version confusion? I’m referring to .NET Framework versioning confusion. I know that I have frequently been asked by customers questions like:

Discussion Points:

•So what is the .NET Framework 3.5?

•Let’s walk through this diagram:

•.NET Framework 3.5

•The .NET Framework 3.5 is an incremental release of the .NET Framework. It provides several new enhancements including LINQ, ASP.NET 3.5, the CLR Add-in framework and several others.

•The .NET Framework 3.5 builds upon the previous versions of the framework, namely the .NET Framework 2.0 and 3.0. More specifically, you can think of it as though the .NET Framework 3.5 has a dependency on the .NET Framework 3.0 with SP1 and 2.0 with SP1.

•.NET Framework 3.0

•The .NET Framework 3.0, which was formerly known as WinFx, introduced several key new technologies including:

•Windows Presentation Foundation – provides the ability to build rich, interactive client applications

•Windows Communication Foundation – provides a common programming model for building services and connecting applications

•Windows Workflow Foundation – provides the ability to define declarative, long-running workflows

•Windows CardSpace – provides a safer and more secure alternative to username and password authentication within web sites and rich client applications

•.NET Framework 2.0

•Finally, the .NET Framework 2.0, which was initially released in 2005 provides the common language runtime and base class libraries that are used by the .NET Framework 3.0 and 3.5 components.

•So how will developers get the .NET Framework 3.5?

•The .NET Framework 3.5 will be available as an optional update through Windows Update, as a bootstrapper installation, and as a full package.

•With all of these packages, your machine will be examined during the installation and the .NET Framework 2.0 with SP1, 3.0 with SP1, and the new 3.5 assemblies will be installed.

•The setup for the .NET Framework 3.5 will only install the necessary bits. So if the .NET Framework 2.0 or 3.0 is already installed, then only the service packs and the 3.5 bits will be added.

38

Page 39: Net Framework

39

Page 40: Net Framework

40

Page 41: Net Framework

41

Page 42: Net Framework

42

Page 43: Net Framework

43

Page 44: Net Framework

CLR Hosting

The .NET Framework runs on top of Microsoft Windows. This means that the .NET Framework

must be built using technologies that Windows can interface with. For starters, all

managed module and assembly files must use the Windows portable executable (PE) file

format and be either a Windows EXE file or a dynamic-link library (DLL).

44

Page 45: Net Framework

45

Page 46: Net Framework

46

Page 47: Net Framework

Reference

47

Page 48: Net Framework

48