Appendix B. Examining the .Net Class Libraries Using the Object Browser

To be successful in .NET programming requires not only that you know the language you are using (C# in this case) but that you be familiar with the classes in the .NET Framework class library. Navigating the huge number of classes in the class library is a daunting task, and it takes a developer many months to get acquainted with the different classes. This appendix summarizes the features of the various versions of the .NET Framework and explains how to use the Object Browser feature in Visual Studio 2008 to browse the available namespaces and classes in the .NET Framework.

Versions of the .NET Framework

The .NET Framework 3.5 builds upon the previous versions of the .NET Framework, namely, version 2.0, 2.0SP1, 3.0, and 3.0SP1. This is evidenced by the set of assembly references available in the Add Reference dialog (see Figure B-1).

Figure B-1

Figure B.1. Figure B-1

The assemblies have different version numbers — some are version 2.0, while some are 3.0 and the rest 3.5. That is to say, when you develop a .NET 3.5 application, your application is actually using a combinations of .NET 2.0, 3.0, and 3.5 class libraries.

The assemblies for the different versions of the .NET Framework are located in the following directories on your development machine:

  • Version 2.0C:WINDOWSMicrosoft.NETFrameworkv2.0.50727

  • Version 3.0C:Program FilesReference AssembliesMicrosoftFrameworkv3.0

  • Version 3.5C:Program FilesReference AssembliesMicrosoftFrameworkv3.5

When you install Visual Studio 2008 on a computer without the previous versions of the .NET Framework, all of these assemblies are installed automatically. The following sections discuss the key components contained in each version of the .NET Framework.

.NET Framework 2.0

The .NET Framework 2.0 is a major upgrade of the .NET Framework and is shipped with Visual Studio 2005. The previous versions of the .NET Framework — 1.0 and 1.1 — are completely separate from each other; each has its own set of assemblies and Common Language Runtime (CLR). In fact, a computer can have three different versions of the .NET Framework installed — 1.0, 1.1, and 2.0. Each of these frameworks can exist on its own and does not rely on previous versions.

The main features in .NET Framework 2.0 are:

  • Common Language Runtime (CLR)

  • Support for generics

  • Compilers for the .NET languages — C#, VB, C++, and J#

  • Base Class Library

  • ASP.NET

  • ADO.NET

  • Windows Forms

  • Web Services

The .NET Framework 2.0 SP1 updates the CLR and several assemblies.

.NET Framework 3.0

The .NET Framework 3.0 ships with Windows Vista and is built on top of the .NET Framework 2.0. Hence, installing .NET Framework 3.0 also requires .NET Framework 2.0 to be installed. .NET Framework 3.0 ships with three new technologies:

  • Windows Presentation Foundation (WPF)

  • Windows Communication Foundation (WCF)

  • Windows Workflow (WF)

The .NET Framework 3.0 SP1 updates the CLR and several assemblies shipped with the Framework.

.NET Framework 3.5

The .NET Framework 3.5 includes several new technologies and is shipped with Visual Studio 2008. The main features in .NET Framework 3.5 are:

  • Language Integrated Query (LINQ)

  • New compilers for C#, VB, and C++

  • ASP.NET AJAX

  • New types in the Base Class Library

Using the Object Browser

Because of the sheer size of the .NET Framework class libraries, it is always a daunting task for beginners using this framework to navigate through the large number of classes available. Fortunately, Visual Studio 2008 ships with the Object Browser, a utility that enables you to quickly search through the list of class libraries available in the .NET Framework.

To use the Object Browser (see Figure B-2), launch Visual Studio 2008 and choose View

Using the Object Browser
Figure B-2

Figure B.2. Figure B-2

The left panel lists the assemblies (.dll files) available. You can expand on each assembly to view the namespaces contained within it.

Figure B-3 shows some of the information displayed by the Object Browser.

Figure B-3

Figure B.3. Figure B-3

You can expand a namespace to reveal the classes, delegates, and enumerations contained within it. Select a class and its associated members (methods, properties, events, and so on) are displayed in the top-right panel. Selecting a member of the class provides a detailed description of the member, such as its summary, parameters, and exceptions.

At the top of the Object Browser, you can select the list of components that you want to view (see Figure B-4).

Figure B-4

Figure B.4. Figure B-4

If the component you want to view is not listed in the Object Browser, select Edit Custom Component Set and choose the component you want to view in the Edit Custom Component Set dialog (see Figure B-5).

Figure B-5

Figure B.5. Figure B-5

The most useful feature of the Object Browser is its search capability. Say that you want to perform compression for your application and you are not sure which class to use for this purpose. Simply type a keyword (compression, for example) into the search box (see Figure B-6) and press Enter.

Figure B-6

Figure B.6. Figure B-6

The Object Browser lists all the namespaces, classes, and so on that are related to the keyword you entered. In this example, you can find the System.IO.Compression namespace that contains the classes you need to use (see Figure B-7) — DeflateStream and GZipStream.

Clicking on a namespace shows you which assembly contains that namespace. System.IO.Compression, for example, is contained within the System.dll assembly.

Figure B-7

Figure B.7. Figure B-7

Clicking an assembly link takes you to the assembly where you can examine all the namespaces contained with it (see Figure B-8). In this example, you can see that the System assembly is a member of the three versions of the .NET Framework — 2.0, 3.0, and 3.5. That's a useful feature because if you use an assembly that belongs only to .NET Framework 3.5, for instance, then you need to ensure that the computer running your application has the latest version of the Framework.

Figure B-8

Figure B.8. Figure B-8

Once you have selected an assembly, you can also click the Add to Reference button (see Figure B-9) in the Object Browser to add a reference to the assembly.

Figure B-9

Figure B.9. Figure B-9

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.221.185.155