Sunday, February 20, 2005

Application Blocks for .NET

Designing distributed applications is no simple task. Before finalizing architecture many decisions need to be taken keeping in view about applications abilities in terms of the security, scalability, availability, and maintainability, to name a few. Application blocks do play a vital role and will have an impact on the architecture, design and implementation of the target infrastructure.
There are various application blocks discussed in Microsoft patterns & practices site that would help you design & build your system. I tried to consolidate so as to help to understand choices set of layers of components that would be used to model your application.

Major application blocks are

· User Interface Process Application Block
· Aggregation Application Block
· Data Access Application Block
· Exception Management Application Block
· Asynchronous Invocation Application Block
· Caching Application Block
· Configuration Management Application Block
· Updater Application Block

User Interface Process Application Block

A base class (ControllerBase) and User Interface Process Manager component that allows to separate logic & state of a user process from the UI needed to collect data and navigate. It includes a set of persistence managers that allows saving the state of the process in database viz., SQL Server, an ASP.NET session, or a custom store.

Where to use
Use it when you need to implement the same process in different types of applications (Windows Forms, Web forms) or want to allow users to resume a session at a later time. Also good for wizard-based applications.

Aggregation Application Block

A component that dispatches Service Agents to collect information from various sources for the application. The application then makes requests to the aggregate component and it returns a single XML document of the collected data. It uses the Exception Management Block and can be used with both the Asynchronous Block and the Caching Block.

Where to use
Use it when your application needs to bring together data from various sources and those sources may change over time. The Aggregation Block serves to abstract the underlying data sources.

Data Access Application Block

Implements a data access helper component, SqlHelper, which helps execute statements against SQL Server 7.0 and higher by exposing a set of static methods and reduces the amount of data access code you have to write. V2.0 supports the .NET Framework v1.1.

Where to use
Use it if you are using SQL Server as the database and wish to reduce the amount of data access code you write. Can use it internally in your own data access classes. Versions of SqlHelper for OleDb and Oracle written in C# are included in the Nile 3.0 sample application.

Exception Management Application Block

Provides a simple and flexible mechanism for publishing exception information through an ExceptionManager class. Also supports filtering and creating your own exception publishers to publish data to sources other than files and event logs using text and XML. Also provides a BaseApplicationException class from which to derive, that collects additional environmental information.

Where to use
Use it as the basis for your exception-handling framework. Ideal for applications that use exception chaining or wrapping and pass exceptions up the call stack. Custom publishers can be used to log exception information to shared databases.

Asynchronous Invocation Application Block

A component that dispatches requests on background threads and then notifies the application when complete. It uses the Exception Management and Data blocks. This block is meant to be used with the Aggregate Block and can work with the Caching block.

Where to use
Use it when the data sources your application communicates with may require a lengthy call. Using the Async Block makes it appear as if the application is more responsive by allowing Web pages to be built incrementally.

Caching Application Block

Allows applications to make requests of a CacheManager object that either returns the data or invokes a Service Agent to retrieve it. Allows items to be expired from cache and cached data to be stored in a variety of format including SQL Server, memory mapped files, or a Singleton object. It uses both the Exception Management and Data Blocks. Can also be used with the Async and Aggregation blocks.

Where to use
Use it when you need to cache data in Windows Forms or other non-Web based applications. ASP.NET provides its own cache and so would not typically be required for Web applications. Important to use for improving performance.

Configuration Management Application Block

A component that abstracts the location of configuration information used in an application and adds features including encryption, caching, and extensibility. It also adds the ability to both read and write the configuration data.

Where to use
Use it when your application might require its configuration data to be stored in different locations at different times. Also take advantage of it for encrypting sensitive information.

Updater Application Block

A component that can be used to download new versions of applications to client machines (using BITS for example). Includes a manifest to specify all the related files and ensure the entire application is downloaded. Provides optional file verification and support for custom downloading and verification components. It uses the Exception Management Block.

Where to use
Use it when your application needs to auto-update with new assemblies or when you are writing a service to provide client machines with updates to a variety of applications.

Next step
I hope these would help while designing & building applications to architect or developer lead. Hell lot of information with code sample are given at Microsoft patterns & practice website which would help you for in-depth understanding of each blocks.


Microsoft released Latest Enterprise Library in January 2005 which included all these Application Blocks.

User Interface Process Application Block can be downloaded from