Enterprise Library New Version 6

This article introduces Enterprise Library and explains what its uses are.

Microsoft has released Enterprise Library version 6.0 in April-2013 but it didn't get much notice since Entity Framework leads in data access technology. Entity Framework as a full ORM getting more popular but Enterprise Library has its own class and usage scope. Entity Framework provides you more option as you can create database from code classes and can be used if application is looking for ORM.

Enterprise Library is a more robust framework or class library written with performance and resource management best practices. Instead of reinvesting the wheel for data access framework, or for other purposes, you can easily plug this library into your application. It also has blocks for Windows Azure or cloud specific. It's a binaries version that is pre-compiled and strongly typed and can be downloaded for direct use. If you are willing to extend or customize it on top of the Enterprise Library source code then download its SourceCode bundle that is available under the Microsoft Public License, in other words it is royalty-free.

Enterprise Library is basically a collection of application blocks. These application blocks are for helping developers by providing reusable components (for example, Data Application Block is for common data access jobs). These blocks are easy to plug into projects. Enterprise Library comes with an easy configuration tool that makes it easier to plug required application blocks into your application. Most developers though plug in these application blocks programmatically since this approach is also easy.

Microsoft always introduces new technology to provide more help and robust services with easy access.

Benefits

One can see the following benefits in using it:

  1. Ease of use
  2. Easily extensible (application blocks come with source code and Microsoft allows you to extend it without royalty)
  3. Well documented
  4. Availability of a wide range of helpfull resources
  5. Consistency
  6. Integrationof blocks ( free to use any application block independently since they are inintegrated well)
  7. Free (Microsoft Public License - royalty free)
  8. Well written with good practices

Since the newer version of the Enterprise Library is targeting the new version of the .Net Framework 4.5, it has deprecated many application blocks with functionalities that are now well handled by the .Net Framework itself (for example Async). This new library is well written for both in-premise as well as cloud applications. The most important thing with the new version is that it has reduced much of its dependencies between application blocks compared to earlier versions. This library provides many highly configurable features to manage repetitive tasks, such as data accessing, logging, validation, caching, exception management and so on.

A look at Microsoft Enterprise Library version 6.0

Microsoft Enterprise Library version 6.0 contains the following application blocks:

  1. Data Access Application Block

    (Provides easy database access functionality in both synchronous and asynchronous data access and returning data in various formats.)
     
  2. Exception Handling Application Block
  3. Logging Application Block. Version 6.0 has asynchronous logging capabilities.
  4. Policy Injection Application Block
  5. Semantic Logging Application Block
  6. Transient Fault Handling Application Block
  7. Unity Application Block
  8. Validation Application Block

It has added the following two new blocks:

  1. Semantic Logging Application Block and
  2. Transient Fault Handling Application Block

It has been improved much more, the following are only related with logging and configuration:

  1. Logging Application Block enhancements:

    • JSON formatter
    • AsynchronousTraceListenerWrapper (allows you to write messages asynchronously)
     
  2. New programmatic configuration that doesn't require a container

It has deprecated some blocks.

As I mentioned above, since this new Enterprise Library is targeting the more powerful new .Net Framework version, the following application blocks have been retired and no longer exist in Enterprise Library v6.0:

  1. CachingApplication Block
  2. CryptographyApplication Block
  3. SecurityApplication Block

How to use it

Download the latest Enterprise Library from Patterns & Practices - Enterprise Library at CodePlex website.

It is very easy to use, just plug the required application blocks into projects by referencing the assemblies and configuring the settings. NuGet makes it very easy to get started since it does all the required things in one easy step and makes it ready to use. We can also configure application blocks using a tool that comes with the Enterprise Library.

Each application block contains DLLs (assemblies). To use a specific block, you need to reference the related DLLs only. There are mainly 3 types of assemblies (DLLs), Common assembly, main application block assemblies and Unity assemblies. Common assemblies are required for dependent application blocks and Unity assemblies are only required when specific unity references are being done in the project.

After referencing and configuring, we can use the code of application block into our application. For convenience, we can import the root namespace using a "using" statement in C#. For example:

using Microsoft.Practices.EnterpriseLibrary.Data;