Click here to Skip to main content
13,258,269 members (48,354 online)
Click here to Skip to main content
Add your own
alternative version


6 bookmarked
Posted 12 Feb 2013

Reusability defined by Microsoft Enterprise Library

, 12 Feb 2013
Rate this:
Please Sign up or sign in to vote.
This is an overview of Enterprise Library and how the use of it is making developer’s life easy.

Wikipedia says “The Microsoft Enterprise Library is a set of tools and programming libraries for the Microsoft .NET Framework. It provides an API to facilitate proven practices in core areas of programming including data access, security, logging, exception handling and others.”

The above definition is somewhat high level so I pitched in with my thoughts.

  1. These are code blocks which are dedicated to perform some individual functions.
  2. These are code blocks which are common in projects independent of the type of project.
  3. These are code blocks which are prepared by Microsoft so can be entrusted with efficiency,industry standards,security, reliability and compliance.

With all the points in mind, a projects can be entrusted with reduced development costs and efforts. For example, the Data Access Application Block provides access to the most frequently used features of ADO.NET, exposing them through easily used classes.

We have the following application blocks in Microsoft Enterprise Library 5.0.

  • Caching Application Block – allows developers to incorporate a local cache in their applications. Pluggable cache providers and persistent backing stores are supported.
  • Data Access Application Block -  allows developers to incorporate standard database functionality in their applications.
  • Cryptography Application Block – allows developers to include encryption and hashing functionality in their applications.
  • Exception Handling Application Block – allows developers and policy makers to create a consistent strategy for processing exceptions that occur throughout the architectural layers of enterprise applications.
  • Logging  Application Block – allows developers to incorporate standard logging and instrumentation functionality in their applications.
  • Unity Application Block- used as a lightweight and extensible dependency injection container with support for constructor, property, and method call injection, as well as instance and type interception.
  • Security Application Block – allows developers to incorporate security functionality in their applications. Applications can use the application block in a variety of situations, such as authenticating and authorizing users against a database, retrieving role and profile information, and caching user profile information.
  • Validation Application Block- to create validation rules for business objects that can be used across different layers of their applications.

Before using Enterprise Library, Please follow the minimum requirement mentioned below.

  • Microsoft Visual Studio 2008
  • Microsoft Enterprise Library 4.1 [Now we have 5.0 available and 6.0 in progress]

Now follow these steps

  1. Reference and Deploy : There is no need to include all the dlls, just check the requirements and include only the common dlls, plus the specialized one as per the requirements. Either, Add a reference the precompiled signed assemblies or install them in the global assembly cache (GAC) or just copy them into your application’s bin folder.
  2. Configuration: Now is the time to change the configuration file. To do that, we can use the configuration tools and add the required blocks or another option is to configure them programmatically. For example, connection string, target for logging, policies etc..
  3. Code: Finally we have all the objects from the dlls available for use. For example, the Logging Application Block provides a LogWriter object that makes it easy to create and write log entries to a wide variety of targets.

Example: Working with the Logging Application Block

Add a reference to Logging Application Block


Config Options:

<loggingConfiguration name="Logging Application Block" tracingEnabled="true"

defaultCategory="General" logWarningsWhenNoCategoriesMatch="true">
<add databaseInstanceName="LoggingDatabase" writeLogStoredProcName="WriteLog"

addCategoryStoredProcName="AddCategory" formatter="Text Formatter"

listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Database.Configuration.FormattedDatabaseTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

traceOutputOptions="None" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.Database.FormattedDatabaseTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

name="DatabaseLogger" />
<add switchValue="All" name="ExceptionLog">
<add name="DatabaseLogger" />

Code: Logger and LogEntry are EntLib objects.

public static void HandleLog(string strLogTitle, string strLogDetails)
<strong>LogEntry</strong> logEntry = new LogEntry();
logEntry.TimeStamp = System.DateTime.Now;
logEntry.Message = strLogDetails;
logEntry.Title = strLogTitle;
logEntry.Severity = TraceEventType.Error;


What’s New in Microsoft Enterprise Library 5.0

We have included the updates available in the most recent version Microsoft Enterprise Library 5.0 from this link:

There are no new blocks; instead the team focused on making the existing blocks shine, on testability, maintainability and learnability. The new features include:

  • Major architectural refactoring that provides improved testability and maintainability through full support of the dependency injection style of development
  • Dependency injection container independence (Unity ships with Enterprise Library, but you can replace Unity with a container of your choice)
  • Programmatic configuration support, including a fluent configuration interface and an XSD schema to enable IntelliSense
  • Redesign of the configuration tool to provide:
    • A more usable and intuitive look and feel
    • Extensibility improvements through meta-data driven configuration visualizations that replace the requirement to write design time code
    • A wizard framework that can help to simplify complex configuration tasks
  • Data accessors for more intuitive processing of data query results
  • Asynchronous data access support
  • Honoring validation attributes between Validation Application Block attributes and DataAnnotations
  • Integration with Windows Presentation Foundation (WPF) validation mechanisms
  • Support for complex configuration scenarios, including additive merge from multiple configuration sources and hierarchical merge
  • Optimized cache scavenging
  • Better performance when logging
  • Support for the .NET 4.0 Framework and integration with Microsoft Visual Studio 2010
  • Improvements to Unity
  • A reduction of the number of assemblies

Vision of Enterprise Library 6.0

Here’s the formal vision for Microsoft Enterprise Library 6.0:

For developers, solution architects, DevOps and IT Pros building, extending and maintaining LOB systems on Microsoft platforms (.NET Framework 4.5 and Windows Azure), Microsoft Enterprise Library 6.0 will provide guidance and reusable components designed to encapsulate recommended practices for end-to-end application development in .NET which facilitate ease of use, consistency, and extensibility.


This is an overview of Enterprise Library and how the use of it is making developer’s life easy.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Himanshu DS
Web Developer
India India
I am a regular developer working on c#,,sql,cms,digital marketing related sites. Through my blog, I am showing the non-technical part of our daily technical terms and processes which can be used to describe it to a layman.Sometimes I write basic technical posts also.

You may also be interested in...


Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.171114.1 | Last Updated 12 Feb 2013
Article Copyright 2013 by Himanshu DS
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid