Touring Base Class Library Enhancements As the core API set underpinning managed application development in .NET, the Base Class Libraries, receive several long-awaited and notable additions in the Whidbey release.The Base Class Libraries (BCL) provide a standardized set of managed APIs to accomplish all of the common and most widely executed application tasks. BCL enhancements surface in as performance-based improvements, class-oriented feature additions, and the introduction of previously missing functionality through entirely new classes. The Base Class Libraries were first introduced as a core component of the .NET Framework back in January 2002. The introduction of the BCL represented a huge step forward in simplicity and consistency of API design for application development. Through provision of a standard hierarchical design known as namespaces, the BCL removed many of the downsides but did not eliminate all of the need for leveraging unmanaged or third-party APIs. | " | The ability to leverage the Data Protection API (DPAPI) takes a dramatic step forward in Whidbey. The ProtectedData and ProtectedMemory classes simplify the process of encrypting data to a single line of code.
| " |
The .NET Framework 1.0/1.1 provided a BCL set that can be segmented into three functionality groups: a managed group, a managed wrappers group, and a support services group. The managed group contains classes consisting mostly of managed code implementations that replace unmanaged APIs. A perfect example of this is ADO.NET found in System.Data. The second group consists of managed wrappers around code or services still implemented as unmanaged code. An example of this can be found in the System.EnterpriseServices namespace that exposes COM+ Services to managed classes. The final functionality group provides support services to facilitate interoperability between the managed and unmanaged APIs. Many of these classes can be found in System.Runtime.InteropServices. Many of the enhancements to the Whidbey BCL set focus on the managed group of classes. Although the interoperability support provided by the BCL allows seamless use of unmanaged code, providing similar functionality as true managed classes improves the performance, general ease of use, and reduces the dependency on proper installation of the underlying unmanaged code being replaced. The Whidbey BCL offers new classes as well as new features for existing BCL classes that greatly simplify a number of common tasks. Some of these new classes can be considered information classes, designed to facilitate information acquisition. Some BCL enhancements provide improved network support or network-oriented features. Other BCL enhancements offer completely new functionality, some of which I'll describe below. I can't cover all the changes to the BCL in this short space; I will cover some of the more important or noticeable areas of improvements. My article discusses the alpha version of the Whidbey BCL, which will continue to evolve, improve, and change as Microsoft moves through the alpha and beta process. New Classes Many of the new Whidbey BCL classes provide functionality directly through the .NET Framework that were previously available to developers only through COM interoperability and/or third-party APIs, or functionality that could be obtained through substantially less convenient avenues. Obtaining Drive Information One new BCL enhancement, the DriveInfo class which you'll find in the System.IO namespace, provides functionality similar to the FileInfo and DirectoryInfo classes already found in the System.IO namespace. DriveInfo provides methods and properties to query information about a current drive on the system or, through the shared GetDrives method, retrieves an array of DriveInfo objects representing all the logical drive names on a computer. Developers will typically use this class to determine available size, or total size, as shown in Figure 1, or to determine whether a drive is a hard disk, network share, or floppy drive. To retrieve information about the "C" drive, you could use code similar to the following: Dim c As New DriveInfo("C") Console.WriteLine("Data for Drive C:") Console.WriteLine("Avail: {0} bytes", _ c.AvailableFreeSpace) Console.WriteLine("Total Free: {0} bytes", _ c.TotalFreeSpace) Console.WriteLine("Format: {0}", c.DriveFormat) Console.WriteLine("Type: {0}", c.DriveType) Console.WriteLine("Name: {0}", c.Name) Console.WriteLine("Size: {0}", c.TotalSize) Console.WriteLine("Label: {0}", c.VolumeLabel)
 Figure 1: The DriveInfo class provides information about logical drives. Use of the DriveInfo class allows upper- or lower-case logical names in the class constructor, but cannot be used on network shares with a UNC path. | & | | 
By: Michael Thomas Michael Lane Thomas, also known as the .NET Cowboy for his sometimes untamed, Wild West-style passion for .NET, has been a fixture in the development community for many years. A speaker at professional, academic, and Microsoft-internal technical conferences, Michael has been a primary contributor to 26 books, including a multi-year stint as .NET Series Editor for Wiley's/Hungry Minds, going back to the Beta days of .NET. Michael has spent time as industry analyst, commentator, and co-host of a weekly radio talk show. As an exam-junkie, Michael is currently the eighth most certified MCP in the world, passing a total of 62 exams to date. Michael is currently a Developer Evangelist for Microsoft and greatly enjoys exploring the Alpha bits for Whidbey as a Microsoft VS.NET Insider, and his role of daddy to his 1-year-old son Noah, also known as "Mr. Pinchy Cheeks."
mlthomas@microsoft.com | Fast Facts | | Enhancements to the Base Class Library provide sought after functionality missing from the .NET Framework 1.1, including simplified DPAPI-based encryption classes and significant increases in Console class functionality. | |
|