Chapter 4. Framework Class Library Overview

In Chapter 3, we focused on some of the key aspects of the .NET Framework and how to leverage them from C#. However, access to these capabilities isn’t limited to C#.

Almost all the capabilities of the .NET Framework are exposed via a set of managed types known as the .NET Framework Class Library (FCL). Because these types are CLS-compliant, they are accessible from almost any .NET language. FCL types are grouped logically by namespace and are exported from a set of assemblies (DLLs) that are part of the .NET platform.

In order to work effectively in C# on the .NET platform, it is important to understand the general capabilities in the predefined class library. However, the library is far too large to cover completely in this book, as it encompasses approximately 3,540 types grouped into 124 namespaces and exported from 38 different assemblies.

Instead, in this chapter, we give an overview of the entire FCL (broken down by logical area) and provide references to relevant types and namespaces so you can explore their details in the .NET Framework SDK on your own.

Useful tools for exploring the FCL include the .NET Framework SDK documentation, the WinCV.exe class browser, and the ILDasm.exe disassembler (see Chapter 5).

Core Types

The core types are contained in the System namespace. This namespace is the heart of the FCL and contains classes, interfaces, and attributes that all other types depend on. The root of the FCL is the type Object, from which all other .NET types derive. Other fundamental types are ValueType (the base type for structs), Enum (the base type for enums), Convert (used to convert between base types), Exception (the base type for all exceptions), and the boxed versions of the predefined value types. Interfaces used throughout the FCL—such as ICloneable, IComparable, IFormattable, and IConvertible—are defined here (see Section 3.3 in Chapter 3).Extended types such as DateTime, TimeSpan, and DBNull are also available. Other classes include support for delegates (see Section 2.13 in Chapter 2), basic math operations (see Section 3.2 in Chapter 3), attributes (see Section 2.16 in Chapter 2), and exception handling (see Section 2.15 in Chapter 2).

For more information, see the System namespace.

Text

The FCL provides rich support for text. Important types include a String class for handling immutable strings, a StringBuilder class that provides string-handling operations with support for locale-aware comparison operations and multiple string-encoding formats (such as ASCII, Unicode, UTF-7, and UTF-8), and a set of classes that provide regular expression support (see Section 3.5 in Chapter 3).

For more information, see the following namespaces:

System.Text
System.Text.RegularExpressions

An important type in other namespaces is System.String.

Collections

The FCL provides a set of general-purpose data structures such as Array, ArrayList, Hashtable, Queue, Stack, BitArray, and more. Standardized design patterns using common base types and public interfaces allow consistent handling of collections throughout the FCL for both predefined and user-defined collection types (see Section 3.4 in Chapter 3).

For more information, see the following namespaces:

System.Collections
System.Collections.Specialized

An important related type in another namespace is System.Array.

Streams and I/O

The FCL provides good support for accessing the standard input, output, and error streams. Classes are also provided for performing binary and text file I/O, registering for notification of filesystem events, and accessing a secure user-specific storage area known as Isolated Storage.

For more information, see the following namespaces:

System.IO
System.IO.IsolatedStorage

An important related type in another namespace is System.Console.

Networking

The FCL provides a layered set of classes for communicating over the network using different levels of abstraction, including raw socket access; TCP, UDP, and HTTP protocol support; a high-level, request/response mechanism based on URIs and streams; and pluggable protocol handlers (see Section 3.7 in Chapter 3).

For more information, see the following namespaces:

System.Net
System.Net.Sockets

An important related type in another namespace is System.IO.Stream.

Threading

The FCL provides rich support for building multithreaded applications, including thread and thread pool management; thread-synchronization mechanisms such as monitors, mutexes, events, reader/writer locks, etc.; and access to such underlying platform features as I/O completion ports and system timers(see Section 3.8 in Chapter 3).

For more information, see the following namespaces:

System.Threading
System.Timers

Important related types in other namespaces include System.Thread and System.ThreadStaticAttribute.

Security

The FCL provides classes for manipulating all elements of the .NET runtime’s Code Access Security model, including security policies, security principals, permission sets, and evidence. These classes also support cryptographic algorithms such as DES, 3DES, RC2, RSA, DSig, MD5, SHA1, and Base64 encoding for stream transformations.

For more information, see the following namespaces:

System.Security
System.Security.Cryptography
System.Security.Cryptography.X509Certificates
System.Security.Cryptography.Xml
System.Security.Permissions
System.Security.Policy
System.Security.Principal

Reflection and Metadata

The .NET runtime depends heavily on the existence of metadata and the ability to inspect and manipulate it dynamically. The FCL exposes this via a set of abstract classes that mirror the significant elements of an application (assemblies, modules, types, and members) and provide support for creating instances of FCL types and new types on the fly(see Section 3.10 in Chapter 3).

For more information, see the following namespaces:

System.Reflection
System.Reflection.Emit

Important related types in other namespaces include System.Type, System.Activator and System.AppDomain.

Assemblies

The FCL provides attributes that tag the metadata on an assembly with information such as target OS and processor, assembly version, and other information. The FCL also provides classes to manipulate assemblies, modules, and assembly strong names.

For more information, see the following namespace:

System.Reflection

Serialization

The FCL includes support for serializing arbitrary object graphs to and from a stream. This serialization can store and transmit complex data structures via files or the network. The default serializers provide binary and XML-based formatting but can be extended with user-defined formatters.

For more information, see the following namespaces:

System.Runtime.Serialization
System.Runtime.Serialization.Formatters
System.Runtime.Serialization.Formatters.Soap
System.Runtime.Serialization.Formatters.Binary

Important related types in other namespaces include System.NonSerializedAttribute and System.SerializableAttribute.

Remoting

Remoting is the cornerstone of a distributed application, and the FCL provides excellent support for making and receiving remote method calls. Calls may be synchronous or asynchronous; support request/response or one-way modes; can be delivered over multiple transports (such as TCP, HTTP, and SMTP); and can be serialized in multiple formats (such as SOAP and binary). The remoting infrastructure supports multiple activation models, lease-based object lifetimes, distributed object identity, object marshaling by reference and by value, and message interception. These types can be extended with user-defined channels, serializers, proxies, and call context.

For more information, see the following namespaces:

System.Runtime.Remoting
System.Runtime.Remoting.Activation
System.Runtime.Remoting.Channels
System.Runtime.Remoting.Channels.Http
System.Runtime.Remoting.Channels.Tcp
System.Runtime.Remoting.Contexts
System.Runtime.Remoting.Lifetime
System.Runtime.Remoting.Messaging
System.Runtime.Remoting.Metadata
System.Runtime.Remoting.MetadataServices
System.Runtime.Remoting.Proxies
System.Runtime.Remoting.Services

Important related types in other namespaces include System.AppDomain, System.ContextBoundObject, System.ContextStaticAttribute, and System.MarshalByRefObject.

Web Services

Logically, web services are simply an instance of remoting. In reality, the FCL support for web services is considered part of ASP.NET and is largely separate from the CLR remoting infrastructure. Classes and attributes exist for describing and publishing web services, discovering which web services are exposed at a particular endpoint (URI), and invoking a web service method.

For more information, see the following namespaces:

System.Web.Services
System.Web.Services.Configuration
System.Web.Services.Description
System.Web.Services.Discovery
System.Web.Services.Protocols

Data Access

Th e FCL includes a set of classes that access data sources and manage complex data sets. Known as ADO.NET, these classes are the managed replacement for ADO under Win32. ADO.NET supports both connected and disconnected operations, multiple data providers (including nonrelational data sources), and serialization to and from XML.

For more information, see the following namespaces:

System.Data
System.Data.Common
System.Data.OleDb
System.Data.SqlClient
System.Data.SqlTypes

XML

The FCL provides broad support for XML 1.0, XML schemas, and XML namespaces, with two separate XML parsing models (a DOM2-based model and a pull-mode variant of SAX2) and implementations of XSL/T, XPath, and SOAP 1.1.

For more information, see the following namespaces:

System.Xml
System.Xml.Schema
System.Xml.Serialization
System.Xml.XPath
System.Xml.Xsl

Graphics

The FCL includes classes to support working with graphic images. Known as GDI+, these classes are the managed equivalent of GDI under Win32 and include support for brushes, fonts, bitmaps, text rendering, drawing primitives, image conversions, and print-preview capabilities.

For more information, see the following namespaces:

System.Drawing
System.Drawing.Design
System.Drawing.Drawing2D
System.Drawing.Imaging
System.Drawing.Printing
System.Drawing.Text

Rich Client Applications

The FCL includes support for creating classic GUI applications. This support is called Windows Forms and consists of a forms package, a predefined set of GUI components, and a component model suited to RAD designer tools. These classes provide varying degrees of abstraction from low-level, message-loop handler classes to high-level layout managers and visual inheritance.

For more information, see the following namespaces:

System.Windows.Forms
System.Windows.Forms.Design

Web-Based Applications

The FCL includes support for creating web-based applications. This support is called Web Forms and consists of a server-side forms package that generates HTML UI, a predefined set of HTML-based GUI widgets, and a component model suited to RAD designer tools. The FCL also includes a set of classes that manage session state, security, caching, debugging, tracing, localization, configuration, and deployment for web-based applications. Finally, the FCL includes the classes and attributes that produce and consume web services, which were described previously in Section 4.12. Collectively, these capabilities are known as ASP.NET and are a complete replacement for ASP under Win32.

For more information, see the following namespaces:

System.Web
System.Web.Caching
System.Web.Configuration
System.Web.Hosting
System.Web.Mail
System.Web.Security
System.Web.SessionState
System.Web.UI
System.Web.UI.Design
System.Web.UI.Design.WebControls
System.Web.UI.HtmlControls
System.Web.UI.WebControls

Globalization

The FCL provides classes that aid globalization by supporting code-page conversions, locale-aware string operations, date/time conversions, and the use of resource files to centralize localization work.

For more information, see the following namespaces:

System.Globalization
System.Resources

Configuration

The FCL provides access to the .NET configuration system, which includes a per-user and per-application configuration model with inheritance of configuration settings, and a transacted installer framework. Classes exist both to use the configuration framework and to extend it.

For more information, see the following namespaces:

System.Configuration
System.Configuration.Assemblies
System.Configuration.Install

Advanced Component Services

The FCL provides support for building on the COM+ services such as distributed transactions, JIT activation, object pooling, queuing, and events. The FCL also includes types that provide access to reliable, asynchronous, one-way messaging via an existing Message Queue infrastructure (MSMQ). The FCL also includes classes that provide access to existing directory services (Active Directory).

For more information, see the following namespaces:

System.DirectoryServices 
System.EnterpriseServices
System.EnterpriseServices.CompensatingResourceManager
System.Messaging

Diagnostics and Debugging

The FCL includes classes that provide debug tracing with multilistener support; access to the event log; access to process, thread, and stack frame information; and the ability to create and consume performance counters.

For more information, see the following namespaces:

System.Diagnostics
System.Diagnostics.SymbolStore

Interoperating with Unmanaged Code

The .NET runtime supports bidirectional interop with unmanaged code via COM, COM+, and native Win32 API calls. The FCL provides a set of classes and attributes that support this, including precise control of managed-object lifetime and the option of creating user-defined custom marshalers to handle specific interop situations.

For more information, see the following namespaces:

System.Runtime.InteropServices
System.Runtime.InteropServices.CustomMarshalers
System.Runtime.InteropServices.Expando

Important types in other namespaces include System.Buffer.

Compiler and Tool Support

In the .NET runtime, components are distinguished from classes by the presence of additional metadata and other apparatus that facilitate the use of component forms packages such as Windows Forms and Web Forms. The FCL provides classes and attributes that support both the creation of components and the creation of tools that consume components. These classes also include the ability to generate and compile C#, JScript, and VB.NET source code.

For more information, see the following namespaces:

Microsoft.CSharp 
Microsoft.JScript 
Microsoft.VisualBasic 
Microsoft.Vsa
System.CodeDom
System.CodeDom.Compiler
System.ComponentModel
System.ComponentModel.Design
System.ComponentModel.Design.Serialization
System.Runtime.CompilerServices

Runtime Facilities

The FCL provides classes that can control runtime behavior. The canonical examples are the classes that control the garbage collector and those that provide strong and weak reference support.

For more information, see the following namespace:

System

An important related type in another namespace is System.Runtime. InteropServices.GCHandle.

Native OS Facilities

The FCL provides support for controlling existing NT services and creating new ones. It also provides access to certain native Win32 facilities such as the Windows registry and the Windows Management Instrumentation (WMI).

For more information, see the following namespaces:

Microsoft.Win32
System.Management
System.Management.Instrumentation
System.ServiceProcess

Undocumented Types

The assemblies that make up the .NET Framework also export many types and namespaces that are not documented. These types and namespaces generally represent either implementation details that are subject to change, vestigial code from earlier betas, or tool-specific code that happens to be managed and is therefore subject to examination via reflection. Regardless of the reason, one cannot count on undocumented types, nor expect any support from Microsoft.

That said, there is useful information to be gained from investigating these private implementation details. Examples of this include: programmatic access to the GAC; predefined Win32 structures and COM interfaces, such as internals of SoapSuds.exe, RegAsm.exe, TlbImp.exe and TlbExp.exe; and browser, tool and OS integration helpers.

Many of the documented namespaces include additional undocumented types. Additionally, the following namespaces are completely undocumented:

Accessibility
IEHost.Execute
Microsoft.CLRAdmin
Microsoft.IE
Microsoft.JScript.Vsa
Microsoft.VisualBasic.CompilerServices
Microsoft.VisualBasic.Vsa
Microsoft.VisualC
Microsoft_VsaVb
RegCode
SoapSudsCode
System.Diagnostics.Design
System.EnterpriseServices.Internal
System.Messaging.Design
System.Runtime.Remoting.Metadata.W3cXsd2001
System.ServiceProcess.Design
System.Web.Handlers
System.Web.RegularExpressions
System.Web.Services.Configuration
System.Web.Util
System.Windows.Forms.ComponentModel.Com2Interop
System.Windows.Forms.PropertyGridInternal
TlbExpCode
TlbImpCode

To investigate these types and namespaces, use ILDasm.exe to examine the metadata and MSIL.

Get C# Essentials, 2nd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.