What Is microsoft net? o Difficulty in integrating Internet technologies rnet-based user interfaces o No standard way for systems and processes to communicate over the Internet a Expensive, difficult, and undependable deployment Poor cross-language integration o Weaknesses in the most popular Microsoft tool-Visual Basic o Lack of full object orientation, which made it impossible to produce frameworks o One threading model that did not work in some contexts a poor integration with the Internet It is important to note that all pre- NET platforms, such as Java, also have some of these drawbacks, as well as unique ones of their own. The drawbacks related to the Internet are particularly ubiquitous. Microsoft. NET was created with the Internet in mind. It was also designed specifically to overcome the limitations of COM and products such as Visual Basic 6 and Active Server Pages. As a result, all of the pre- ding limitations have been eliminated or significantly reduced in Microsoft NET and Visual Studio 2005 An over view of the. net Framework First and foremost, NET is a framework that covers all the layers of software development above the operating system level. It provides the richest level of integration among presentation technologies, com- ponent technologies, and data technologies ever seen on a Microsoft, or perhaps any, platform. Second, the entire architecture has been created to make it as easy to develop Internet applications as it is to develop for the desktop The NET Framework actually"wraps"the operating system, insulating software developed with. NET from most operating system specifics such as file handling and memory allocation. This prepares for a possible future in which the software developed for NET is portable to a wide variety of hardware and VSNET supports Windows 2003, Windows XP, and all versions of Windows 2000. Programs created for NET can also run under Windows NT, Windows 98, and Windows Me, though VS NET does not run on these systems. Note that in some cases certain service packs quired to run NET. The major components of the Microsoft NET Framework are shown in Figure 1-1 The framework starts all the way down at the memory management and component loading level and goes all th up to multiple ways of rendering user and program interfaces. In between, there are layers that provide just about any system-level capability that a developer would need
❑ Difficulty in integrating Internet technologies: ❑ Hard to produce Internet-based user interfaces ❑ No standard way for systems and processes to communicate over the Internet ❑ Expensive, difficult, and undependable deployment ❑ Poor cross-language integration ❑ Weaknesses in the most popular Microsoft tool — Visual Basic: ❑ Lack of full object orientation, which made it impossible to produce frameworks in Visual Basic ❑ One threading model that did not work in some contexts ❑ Poor integration with the Internet ❑ Other weaknesses such as poor error-handling capabilities It is important to note that all pre-.NET platforms, such as Java, also have some of these drawbacks, as well as unique ones of their own. The drawbacks related to the Internet are particularly ubiquitous. Microsoft .NET was created with the Internet in mind. It was also designed specifically to overcome the limitations of COM and products such as Visual Basic 6 and Active Server Pages. As a result, all of the preceding limitations have been eliminated or significantly reduced in Microsoft .NET and Visual Studio 2005. An Overview of the .NET Framework First and foremost, .NET is a framework that covers all the layers of software development above the operating system level. It provides the richest level of integration among presentation technologies, component technologies, and data technologies ever seen on a Microsoft, or perhaps any, platform. Second, the entire architecture has been created to make it as easy to develop Internet applications as it is to develop for the desktop. The .NET Framework actually “wraps” the operating system, insulating software developed with .NET from most operating system specifics such as file handling and memory allocation. This prepares for a possible future in which the software developed for .NET is portable to a wide variety of hardware and operating system foundations. VS.NET supports Windows 2003, Windows XP, and all versions of Windows 2000. Programs created for .NET can also run under Windows NT, Windows 98, and Windows Me, though VS.NET does not run on these systems. Note that in some cases certain service packs are required to run .NET. The major components of the Microsoft .NET Framework are shown in Figure 1-1. The framework starts all the way down at the memory management and component loading level and goes all the way up to multiple ways of rendering user and program interfaces. In between, there are layers that provide just about any system-level capability that a developer would need. 3 What Is Microsoft .NET? 04_575368 ch01.qxd 10/7/05 10:50 PM Page 3
Chapter 1 ASPNE Windows Forms eb Forms ontrols ASP. NET Application Services Windows Application Service NET Framework Base Classes ADO.NET omponent Model Security Etc Common Language Runtime Memory ManagementCommon Type System[ Lifecycle Monitoring Figure 1-1 At the base is the common language runtime, often abbreviated to Clr. This is the heart of the NET Framework-it is the engine that drives key functionality. It includes, for example, a common system of datatypes. These common types, plus a standard interface convention, make cross-language inheritance possible. In addition to allocation and management of memory, the Clr also does reference tracking for objects and handles garbage collection The middle layer includes the next generation of standard system Services such as classes that manage data and Extensible Markup Language(XML). These services are brought under control of the Framework, making them universally available and making their usage consistent across languages The top layer includes user and program interfaces. Windows Forms is a new and more advanced way to do standard Win32 screens(often referred to as"smart clients"). Web Forms provides a new Web-based user interface. Perhaps the most revolutionary is Web Services, which provide a mechanism for programs to communicate over the Internet, using SOAP Web Services provide an analog of COM and DCOM for object brokering and interfacing, but based on Internet technologies so that allowance is made even for integration to non-Microsoft platforms. Web Forms and Web Services, which constitute the Internet inter face portion of NET, are implemented by a part of the NET Framework referred to as ASPNET. All of these capabilities are available to any language that is based on the. NET platform, including, of course, vb.net. The common Language runtime We are all familiar with runtimes-they go back further than DOS languages. However, the common language runtime( CLR)is as advanced over traditional runtimes as a machine gun is over a musket. Figure 1-2 shows a quick diagrammatic summary of the major pieces of the CLR. That small part in the middle of Figure 1-2 called Execution support contains most of the capabilities normally associated with a language runtime(such as the VBRUNxXX DLL runtime used with Visual Basic). The rest is new, at least for Microsoft platforms
Figure 1-1 At the base is the common language runtime, often abbreviated to CLR. This is the heart of the .NET Framework — it is the engine that drives key functionality. It includes, for example, a common system of datatypes. These common types, plus a standard interface convention, make cross-language inheritance possible. In addition to allocation and management of memory, the CLR also does reference tracking for objects and handles garbage collection. The middle layer includes the next generation of standard system Services such as classes that manage data and Extensible Markup Language (XML). These services are brought under control of the Framework, making them universally available and making their usage consistent across languages. The top layer includes user and program interfaces. Windows Forms is a new and more advanced way to do standard Win32 screens (often referred to as “‘smart clients”). Web Forms provides a new Web-based user interface. Perhaps the most revolutionary is Web Services, which provide a mechanism for programs to communicate over the Internet, using SOAP. Web Services provide an analog of COM and DCOM for object brokering and interfacing, but based on Internet technologies so that allowance is made even for integration to non-Microsoft platforms. Web Forms and Web Services, which constitute the Internet interface portion of .NET, are implemented by a part of the .NET Framework referred to as ASP.NET. All of these capabilities are available to any language that is based on the .NET platform, including, of course, VB.NET. The Common Language Runtime We are all familiar with runtimes — they go back further than DOS languages. However, the common language runtime (CLR) is as advanced over traditional runtimes as a machine gun is over a musket. Figure 1-2 shows a quick diagrammatic summary of the major pieces of the CLR. That small part in the middle of Figure 1-2 called Execution support contains most of the capabilities normally associated with a language runtime (such as the VBRUNxxx.DLL runtime used with Visual Basic). The rest is new, at least for Microsoft platforms. ASP.NET Web Services Web Forms ASP.NET Application Services Windows Forms Controls Drawing Windows Application Services .NET Framework Base Classes ADO.NET XML Threading IO Component Model Security Diagnostics Etc. Common Language Runtime Memory Management Common Type System Lifecycle Monitoring 4 Chapter 1 04_575368 ch01.qxd 10/7/05 10:50 PM Page 4
What Is microsoft net? Common Type System Securi Garbage collection, stack walk, code manage Class loader and memory layout Figure 1-2 Key Design Goals The design of the Clr is based on the following primary goals: Simpler, faster development d Automatic handling of system-level tasks such as memory management and process 口 Excellent tool support Simpler, safer deployment Notice that many of these design goals directly address the limitations of COM/DNA. Let's look at ome of these in detail Simpler, Faster Development A broad, consistent framework allows developers to write less code, and reuse code more. Using less code is possible because the system provides a rich set of underlying functionality. Programs in. NET access this functionality in a standard, consistent way, requiring less"hardwiring"and customization logic to interface with the functionality than is typically needed today Programming is also simpler in. NET because of the standardization of datatypes and interface conven- tions. As will be discussed later,. NET makes knowledge of the intricacies of COM much less important. The net result is that programs written in vB. NET that take proper advantage of the full capabilities of the NET Framework typically have significantly less code than equivalent programs written in earlier versions of Visual Basic. Less code means faster development, fewer bugs, and easier maintenance Excellent Tool Support Although much of what the Clr does is similar to operating system functionality, it is very much designed to support development languages. It furnishes a rich set of object models that are useful to
Figure 1-2 Key Design Goals The design of the CLR is based on the following primary goals: ❑ Simpler, faster development ❑ Automatic handling of system-level tasks such as memory management and process communication ❑ Excellent tool support ❑ Simpler, safer deployment ❑ Scalability Notice that many of these design goals directly address the limitations of COM/DNA. Let’s look at some of these in detail. Simpler, Faster Development A broad, consistent framework allows developers to write less code, and reuse code more. Using less code is possible because the system provides a rich set of underlying functionality. Programs in .NET access this functionality in a standard, consistent way, requiring less “hardwiring” and customization logic to interface with the functionality than is typically needed today. Programming is also simpler in .NET because of the standardization of datatypes and interface conventions. As will be discussed later, .NET makes knowledge of the intricacies of COM much less important. The net result is that programs written in VB.NET that take proper advantage of the full capabilities of the .NET Framework typically have significantly less code than equivalent programs written in earlier versions of Visual Basic. Less code means faster development, fewer bugs, and easier maintenance. Excellent Tool Support Although much of what the CLR does is similar to operating system functionality, it is very much designed to support development languages. It furnishes a rich set of object models that are useful to Common Type System (Data types, etc.) Intermediate Language (IL) to native code compilers Execution support (traditional runtime functions) Security Garbage collection, stack walk, code manager Class loader and memory layout 5 What Is Microsoft .NET? 04_575368 ch01.qxd 10/7/05 10:50 PM Page 5
Chapter 1 tools like designers, wizards, debuggers, and profilers, and since the object models are at the runtime level, such tools can be designed to work across all languages that use the Clr. It is expected that third parties will produce a host of such tools Simpler, Safer Deployment It is hard for an experienced Windows component developer to see how anything can work without registration, GUIDs, and the like, but the Clr does Applications produced in the NET Framework can be designed to install with a simple XCoPY. That's right-just copy the files onto the disk and run the application(as long as the. NET Framework was previously installed, which is discussed in more detail in the following sections). This hasnt been seen in the Microsoft world since the days of DoS(and some of us really miss it) This works because compilers in the NET Framework embed identifiers(in the form of metadata, to be discussed later) into compiled modules, and the CLr manages those identifiers automatically. The iden- tifiers provide all the information needed to load and run modules, and to locate related modules As a great by-product, the CLR can manage multiple versions of the same component(even a shared component)and have them run side by side. The identifiers tell the Clr which version is needed for a particular compiled module, because such information is captured at compile time. The runtime policy can be set in a module to use the exact version of a component that was available at compile time, to use the latest compatible version, or to specify an exact version. The bottom line is that NET is intended to eradicate dll hell once and for all This has implications that might not be apparent at first. For example, if a program needed to run not feasible in Visual Basic after version 3. That capability reappears with VB.NET. This dramatical Ro directly from a CD or a shared network drive(without first running an installation program), that reduces the cost of deployment in many common scenarios. Another significant deployment benefit in NET is that applications only need to install their own core gic. An application produced in nET does not need to install a runtime, for example, or modules for ADO or XML. Such base functionality is part of the. NET Framework, which is installed separately and only once for each system. The. NET Framework will eventually be included with the operating system and probably with various applications. Those four-disk installs for a VB"Hello world"program are thing of the past. NET programs can also be deployed across the Internet. Version 2.0 of the NET Framework includes a new technology specifically for that purpose called ClickOnce. This is a new capability in NET, supple- menting the older"no touch deployment. "You can read about Click Chapter 19 The. NET Framework, which includes the Clr and the framework base classes, is required on every machine where you want to run NET applications and code. For Windows 2003 and above, the. NET Framework is installed automatically as part of the operating system. For older operating systems, or to install a newer version of the. NET Framework, the NET Framework is a separate installation Deployment of. NET applications is discussed in Chapter 19 Scalability Since most of the system-level execution functions are concentrated in the CLR, they can be optimized and architected to allow a wide range of scalability for applications produced in the. NET Framework. As with most of the other advantages of the CLR, this one comes to all applications with little or no effort
tools like designers, wizards, debuggers, and profilers, and since the object models are at the runtime level, such tools can be designed to work across all languages that use the CLR. It is expected that third parties will produce a host of such tools. Simpler, Safer Deployment It is hard for an experienced Windows component developer to see how anything can work without registration, GUIDs, and the like, but the CLR does. Applications produced in the .NET Framework can be designed to install with a simple XCOPY. That’s right — just copy the files onto the disk and run the application (as long as the .NET Framework was previously installed, which is discussed in more detail in the following sections). This hasn’t been seen in the Microsoft world since the days of DOS (and some of us really miss it). This works because compilers in the .NET Framework embed identifiers (in the form of metadata, to be discussed later) into compiled modules, and the CLR manages those identifiers automatically. The identifiers provide all the information needed to load and run modules, and to locate related modules. As a great by-product, the CLR can manage multiple versions of the same component (even a shared component) and have them run side by side. The identifiers tell the CLR which version is needed for a particular compiled module, because such information is captured at compile time. The runtime policy can be set in a module to use the exact version of a component that was available at compile time, to use the latest compatible version, or to specify an exact version. The bottom line is that .NET is intended to eradicate DLL hell once and for all. This has implications that might not be apparent at first. For example, if a program needed to run directly from a CD or a shared network drive (without first running an installation program), that was not feasible in Visual Basic after version 3. That capability reappears with VB.NET. This dramatically reduces the cost of deployment in many common scenarios. Another significant deployment benefit in .NET is that applications only need to install their own core logic. An application produced in .NET does not need to install a runtime, for example, or modules for ADO or XML. Such base functionality is part of the .NET Framework, which is installed separately and only once for each system. The .NET Framework will eventually be included with the operating system and probably with various applications. Those four-disk installs for a VB “Hello world” program are a thing of the past. .NET programs can also be deployed across the Internet. Version 2.0 of the .NET Framework includes a new technology specifically for that purpose called ClickOnce. This is a new capability in .NET, supplementing the older “no touch deployment.” You can read about ClickOnce in Chapter 19. The .NET Framework, which includes the CLR and the Framework base classes, is required on every machine where you want to run .NET applications and code. For Windows 2003 and above, the .NET Framework is installed automatically as part of the operating system. For older operating systems, or to install a newer version of the .NET Framework, the .NET Framework is a separate installation. Deployment of .NET applications is discussed in Chapter 19. Scalability Since most of the system-level execution functions are concentrated in the CLR, they can be optimized and architected to allow a wide range of scalability for applications produced in the .NET Framework. As with most of the other advantages of the CLR, this one comes to all applications with little or no effort. 6 Chapter 1 04_575368 ch01.qxd 10/7/05 10:50 PM Page 6
What Is microsoft net? Memory and process management is one area where scalability can be built in. The memory manage- ment in the ClR is self-configuring and tunes itself automatically. Garbage collection(reclaiming memory that is no longer being actively used)is highly optimized, and the Clr supports many of the component management capabilities of MTS/COM+(such as object pooling). The result is that compo- ents can run faster and, thus, support more users. This has some interesting side effects. For example, the performance and scalability differences among languages become smaller. All languages compile to a standard bytecode called Microsoft Intermediate Language(MSIL), often referred to simply as IL, and there is a discussion later on how the Clr executes IL. With all languages compiling down to similar bytecode, it becomes unnecessary in most cases to look to other languages when performance is an issue. The difference in performance among NET languages minor-Visual Basic, for example, gives about the same performance as any of the other. NET languages Versions of the Clr are available on a wide range of devices. The vision is for. NET to be running at ll levels, from smart palmtop devices all the way up to Web farms. The same development tools work across the entire range -news that will be appreciated by those who have tried to use older Windows CE development kits Metadata The NET Framework needs lots of information about an application to carry out several automatic func- tions. The design of NET requires applications to carry that information within them. That is, applica- tions are self-describing. The collected information that describes an application is called metadata The concept of metadata is not new. For example, COM components use a form of it called a type library, which contains metadata describing the classes exposed by the component and is used to facilitate Ole Automation. A component's type library, however, is stored in a separate file. In contrast, the metadata in NET is stored in one place-inside the component it describes Metadata in NET also contains more information about the component and is better organized Chapter 6 on the Clr goes into more information about metadata. For now, the most important point for you to internalize is that metadata is key to the easy deployment in NET. When a component is upgraded or moved, the necessary information about the component cannot be left behind. Metadata can never get out of sync with a NET component, because it is not in a separate file. Everything the ClR needs to know to run a component is supplied with the component ultiple-Language Integration and Support The CLr is designed to support multiple languages and allow unprecedented levels of integration mong those languages. By enforcing a common type system, and by having complete control over interface calls, the CLR allows languages to work together more transparently than ever before. The cross-language integration issues of COM simply don' t exist in .NET. It is straightforward in the . NET Framework to use one language to subclass a class implemented another. a class written in Visual Basic can inherit from a base class written in C#, or in CObOl for that matter. The VB program doesn't even need to know the language used for the base class. NET offers full implementation inheritance with no problems that require recompilation when the base class changes Chapter 3 also includes more information on the multiple-language integration features of NET
Memory and process management is one area where scalability can be built in. The memory management in the CLR is self-configuring and tunes itself automatically. Garbage collection (reclaiming memory that is no longer being actively used) is highly optimized, and the CLR supports many of the component management capabilities of MTS/COM+ (such as object pooling). The result is that components can run faster and, thus, support more users. This has some interesting side effects. For example, the performance and scalability differences among languages become smaller. All languages compile to a standard bytecode called Microsoft Intermediate Language (MSIL), often referred to simply as IL, and there is a discussion later on how the CLR executes IL. With all languages compiling down to similar bytecode, it becomes unnecessary in most cases to look to other languages when performance is an issue. The difference in performance among .NET languages is minor — Visual Basic, for example, gives about the same performance as any of the other .NET languages. Versions of the CLR are available on a wide range of devices. The vision is for .NET to be running at all levels, from smart palmtop devices all the way up to Web farms. The same development tools work across the entire range — news that will be appreciated by those who have tried to use older Windows CE development kits. Metadata The .NET Framework needs lots of information about an application to carry out several automatic functions. The design of .NET requires applications to carry that information within them. That is, applications are self-describing. The collected information that describes an application is called metadata. The concept of metadata is not new. For example, COM components use a form of it called a type library, which contains metadata describing the classes exposed by the component and is used to facilitate OLE Automation. A component’s type library, however, is stored in a separate file. In contrast, the metadata in .NET is stored in one place — inside the component it describes. Metadata in .NET also contains more information about the component and is better organized. Chapter 6 on the CLR goes into more information about metadata. For now, the most important point for you to internalize is that metadata is key to the easy deployment in .NET. When a component is upgraded or moved, the necessary information about the component cannot be left behind. Metadata can never get out of sync with a .NET component, because it is not in a separate file. Everything the CLR needs to know to run a component is supplied with the component. Multiple-Language Integration and Support The CLR is designed to support multiple languages and allow unprecedented levels of integration among those languages. By enforcing a common type system, and by having complete control over interface calls, the CLR allows languages to work together more transparently than ever before. The cross-language integration issues of COM simply don’t exist in .NET. It is straightforward in the .NET Framework to use one language to subclass a class implemented in another. A class written in Visual Basic can inherit from a base class written in C#, or in COBOL for that matter. The VB program doesn’t even need to know the language used for the base class. .NET offers full implementation inheritance with no problems that require recompilation when the base class changes. Chapter 3 also includes more information on the multiple-language integration features of .NET. 7 What Is Microsoft .NET? 04_575368 ch01.qxd 10/7/05 10:50 PM Page 7