What Exactly Is the .NET Framework?

What Exactly Is the .NET Framework?

The .NET Framework is the foundation on which you build and run .NET applications. Having such a foundation makes building Visual Basic .NET applications easier, while providing a consistent, simplified programming model. As a Visual Basic 6 developer, you used a programming language that made building a variety of applications easy. The Visual Basic language itself provides the intrinsic data types—such as Integer, Long, and String—as well as some of the most commonly used functions, such as those for string manipulation and data type conversion. As your Visual Basic 6 applications became more sophisticated, you probably used Win32 APIs to perform operations, such as accessing arbitrary registry keys and values, that were not possible with the standard Visual Basic functions. You probably also used the COM component libraries to extend the application's functionality. Probably the most common of these COM objects is the ActiveX Data Objects (ADO) library that your program used for data access. Whenever you added an ADO control, you were using a COM object.

While Visual Basic 6 was flexible enough to offer these different extensibility mechanisms, that flexibility required learning several complex API architectures. First you had to learn how Win32 APIs worked. Next you had to figure out how to call the APIs from Visual Basic 6, which was usually a time-consuming, error-prone task. Next you had to learn how to use various COM components from Visual Basic, which was challenging because each had a different object model.

When you completed a Visual Basic 6 program that utilized Win32 APIs, ADO, and probably many other COM components, you had to think about how to manage the application's deployment along with all the dependent files. A typical nontrivial Visual Basic 6 application's dependency list includes not only the Visual Basic 6 runtime, but also all of the libraries required by the application, such as ADO 2.6. Most times, one or another file was forgotten, only to be discovered when the program crashed on a user's machine.

The idea behind the .NET Framework is to solve these problems. The framework will make it easier for you to develop robust applications without having to learn many different API architectures and without having to deploy and handle versioning for a dozen libraries.

Tapping into the .NET Framework

As you've already seen, you don't have to design all your Visual Basic .NET types from the ground up. The .NET Framework includes classes, interfaces, and value types that help to both expedite and optimize the development process. The framework also gives you tools that allow you to access system functionality. The framework provides types that encapsulate data structures, perform I/O, allow access to information about a loaded class, invoke .NET Framework security checks, encapsulate exceptions, and provide data access. These types make it easy to create rich applications.

It All Starts with the System Namespace

The System namespace—the root for types in the .NET Framework—includes classes that represent the base data types used by all Visual Basic .NET applications. Remember that these base data types are the Object (the root of the inheritance hierarchy), Byte, Char, Array, Int32, String, and so on. As we discussed in the last chapter, many of these types correspond to the primitive data types that the Visual Basic .NET compiler uses.

Along with the base data types, the System namespace contains almost 100 classes that provide functionality ranging from handling exceptions and forming delegates to dealing with core run-time concepts such as application domains and the automatic memory manager. The System namespace also contains 25 second-level namespaces, listed in Table 5-1. Take a moment to review the description of each. You can see how the namespace convention logically segregates functionality, making specific classes easy to find.

Table 5-1  Secondary Namespaces in the System Namespace

Namespaces

Description

System.CodeDom

Contains classes that can be used to represent the elements and structure of a source code document.

System.Collections

Contains interfaces and classes that define various collections of objects, such as lists, queues, arrays, hash tables, and dictionaries.

System.ComponentModel

Provides classes that are used to implement and license components.

System.Configuration

Provides classes that give system run times, administrative tools, applications, and other consumers of configuration information access to configuration information.

System.Data

Consists mostly of classes that constitute the Microsoft ADO.NET architecture. ADO.NET architecture enables you to build components that manage data from multiple data sources.

System.Diagnostics

Provides classes to debug applications and to trace the execution of code.

System.DirectoryServices

Provides access to Active Directory from managed code. The classes in this namespace can be used with any of the Active Directory service providers such as Internet Information Services (IIS), Lightweight Directory Access Protocol (LDAP), Novell NetWare Directory Service (NDS), and WinNT.

System.Drawing

Provides access to GDI+ basic graphics functionality. Additional advanced functionality is provided in the System.Drawing.Drawing2D, System.Drawing.Imaging, and System.Drawing.Text namespaces.

System.EnterpriseServices

Provides transaction-processing functionality.

System.Globalization

Provides localization information on elements such as the current culture, formatting, date, and time for specific locales.

System.IO

Provides types that allow synchronous and asynchronous reading from and writing to data streams and files.

System.Management

Provides classes for the management of system objects and events.

System.Messaging

Provides classes to connect to message queues on the network, send messages to queues, and receive or peek (read without removing) messages from queues.

System.Net

Provides a simple programming interface to many of the protocols found on the network today. For example, the WebRequest and WebResponse classes form the basis of "pluggable protocols." This namespace is an implementation of network services that enables you to develop applications that use Internet resources without worrying about the specific details of the protocol used.

System.Reflection

Contains classes and interfaces that provide a managed view of types, methods, and fields, with the ability to dynamically create and invoke types.

System.Resources

Provides management of resources, such as a resource that contains culture-specific information.

System.Runtime

Provides infrastructure services.

System.Security

Provides the underlying structure of the .NET Framework security system, including interfaces, attributes, exceptions, and base classes for permissions.

System.ServiceProcess

Provides classes to install and run services. Services are long-running executables that do not have a user interface.

System.Text

Contains classes representing ASCII, Unicode, UTF-7, and UTF-8 character encodings; abstract base classes for converting blocks of characters to and from blocks of bytes; and a helper class that manipulates and formats String objects without creating intermediate instances of String.

System.Threading

Provides classes and interfaces that enable multithreaded programming. This namespace includes a ThreadPool class that manages groups of threads, a Timer class that enables a delegate to be called after a specified amount of time, a Mutex class for synchronizing mutually exclusive threads, and classes for thread scheduling, wait notification, and deadlock resolution.

System.Timers

Provides two components that raise an event on an interval or more complex schedule, the Timer and Schedule components respectively.

System.Web

Supplies classes and interfaces that enable browser-server communication. Included are the HTTPRequest class that provides extensive information about the current HTTP request, the HTTPResponse class that manages HTTP output to the client, and the HTTPServerUtility object that provides access to server-side utilities and processes and classes for cookie manipulation, file transfer, exception information, and output cache control.

System.Windows.Forms

Contains classes for creating Windows-based applications (such as a Forms application) and classes for many controls that can be added to forms.

System.Xml

Contains XML classes that provide standards-based support for processing XML.

note

If you are looking for specific functionality, such as file manipulation, go back and scan Table 2-1 to determine which namespace to look in. Because file manipulation is a basic tool, the System.IO namespace is grouped under programming basics.

Working with the Windows API is tricky for all types of programmers. Like many classic Visual Basic programmers, I have several dog-eared copies of both 16-bit and 32-bit Windows API reference books on my shelf. These tomes were invaluable for developing all but the simplest Visual Basic programs as I learned to write Windows applications. If an API's parameters were not entered just right, my computer took a trip to General Protection Fault City. Of course, the computer didn't lock up until run time because the API calls were late bound. I had to create buffers of exactly the correct size for return values and had to deal with all sorts of other nuisances because the parameters had to be entered in a way that the C language, not Visual Basic, could understand. In short, the API was like fire—it could either illuminate or burn.

While the classic Visual Basic IDE provided the API viewer with which to copy function declarations to your code, you really had to know what you were looking for before you even started. Of course, the naming conventions were often anti-intuitive, which mandated taking the API book off the shelf and hunting for exactly what you wanted. Luckily, even though the .NET Framework is massive, it is easier to find what you're looking for because of the logical grouping of classes, consistency of use, and a few handy tools.



Coding Techniques for Microsoft Visual Basic. NET
Coding Techniques for Microsoft Visual Basic .NET
ISBN: 0735612544
EAN: 2147483647
Year: 2002
Pages: 123
Authors: John Connell

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net