I was
introduced to the Microsoft Application Blocks around the time of .NET version
1.1 with the data application block. It does the heavy lifting for you, with all
code written according to Microsoft .NET recommendations, and it greatly simplifies
interacting with data backend (SQL Server in my case).

Since its inception, it
has evolved into the Microsoft Enterprise Library, which includes more features on top of data access. This tour of the library’s offerings focuses on recent changes that allow you to contribute
to its continuing evolution. I’ll begin with an overview of what
comprises the Microsoft Enterprise Library and why you should care about it.


The main
goal of the Microsoft Enterprise Library is to address common software needs.
It meets this goal by offering reusable software components to assist with
building .NET applications.

The library is comprised of eight application blocks:

  • Data Access simplifies working with an underlining
    database while providing methods for performing common tasks like calling
    stored procedures.
  • Exception Handling provides a framework for centralizing exception handling, making
    it easier to manage exceptions. This application block provides implementations for handling
    standard exceptions and for creating custom variations.
  • Logging provides
    everything necessary to create log entries in various locations. Like the
    other application blocks, it allows you to centralize the functionality and thus
    spend your time coding application functionality as opposed to standard,
    repeatable operations like logging.
  • Policy Injection assists with implementing Aspect Oriented Programming techniques within your code. This is achieved by intercepting method calls and invoking handlers before and after those methods based on configuration information. 
  • Semantic Logging facilitates using strongly-typed logging (aka semantic) within your application. This provides a more consistent and standard approach
    to logging, which is beneficial when processing the log data.
  • Transient Fault Handling: Code-named Topaz, it can be used to add support for
    handling transient faults to your code. These type of faults occur infrequently
    and often disappear after a few retries. A good example is network issues
    hampering connecting to a web service.
  • Unity provides a dependency injection container to be used with your code.
  • Validation provides validation routines for common application functions. This includes
    user interface adapters for ASP.NET controls.

I have used
the Data Access, Exception Handling, and Logging application blocks extensively, as these are base functions that are needed in most of my applications. I can pop these thoroughly tested components into my code
and move on to more important tasks. There is no need to worry with these application
blocks about the code working, though it does take time to become
acclimated to using them in code.

changes to the Microsoft Enterprise Library split it into 10 individual code
repositories. This includes one for each application block listed above, individual repositories for the common infrastructure (used by all of the application blocks), and one for
reference implementations. These repositories are hosted on CodePlex. Each application
block has been stripped of dependencies, so they can live and breathe

Throw in
your two cents

Another recent
change to the Microsoft Enterprise Library is a move to what they’re calling
an Open Development Model. It’s not official open source, but it does
open up the library and allow the community to drive changes and improvements. Learn how to contribute to one or more of the projects. Project
and coding guidelines shed light on creating code and working with the project. The
projects use Git
for source code management.

Two goals of
this change are more transparency with what is going on and consistency
with how things are done (standards are published for Microsoft and
external developers). To facilitate the transparency and consistency, each
project or CodePlex site has its own backlog (issues and feature requests) and discussion

A quick scan of the discussion forum for a couple projects doesn’t
show much activity, but then again, the projects were only set up about a
week ago. There are some interesting discussions within the discussion forum for the main Enterprise Library project.

Take a
closer look

Open Development Model is a more open approach to the
development to these tools. I’m not sure I’ll have the chance to contribute to the projects, but the
opportunity to get a closer look at the code created by Microsoft and how the company drives the projects is definitely a learning opportunity.

Using Git is great for
managing the code, but you can easily take a stroll through the source code of your browser, as Figure A demonstrates with the ConnectionString class selected.

Figure A

Browsing the ConnectionString class code in the Data Access Application Block

Be more

There are a
lot of application blocks, so it can be overwhelming when you first confront
them. Each block has its own application, so just focus on the one (or ones) that fit
your needs. There are a number of resources about using the Microsoft Enterprise Library, including Hands-on Labs and the Developer’s Guide. Also, the downloads section of the
CodePlex projects contain valuable information.

In the end, the application
blocks are straightforward to use, and the result is applications with
standard and consistent features — after all, nobody wants or needs to reinvent
the wheel. The application blocks lets you to focus on the more
important code for your project.