Enterprise Library

Microsoft Enterprise Library is a collection of reusable software components designed to assist developers with common enterprise development challenges, it contains standalone application blocks that can be combined to work together to solve various cross-cutting concerns such as DI, logging, error handling, data access, validating input, etcetera. The new version of Enterprise Library has been released, Enterprise Library 6.0. Enterprise Library 6.0 has enhancements for more recent technologies and integrates with ASP.NET MVC and ASP.NET Web API.

In Enterprise Library 6.0, the following application blocks are available,

What's New in Enterprise Library 6.0?

Newly implemented Blocks

Rejected Blocks that have been removed

Other but Important changes

Unity

Unity is also an application block of Enterprise Library that provides a lightweight, extensible dependency injection container with support for constructor, property, and method call injection. It facilitates building loosely coupled applications. And the way we envision Unity 3.0 is that they will be targeted for Windows 8. Microsoft Patterns & practices list the new features of Unity 3.0

What's New in Unity 3.0?

As the Semantic Logging Application Block and Transient Fault Handling Application Block are the newly implemented blocks, let's learn something more about the Semantic Logging Application Block.

Semantic Logging Application Block

Semantic Logging Application Block provides a set of destinations (sinks) to persist application events published using a subclass of the EventSource class from the "System.Diagnostics.Tracing" namespace. It enables developers to have a structured way to log events so that later analysis of the logged information can produce valuable inputs to the business. You can do many of the same things with the Semantic Logging Application Block; you can write log messages to multiple destinations, you can control the format of your log messages, and you can filter what gets written to the log.

To store some errors using semantic logging application block we use,

MyEventSource.Log.UIError(ex.Message);

When you write log messages, what exactly does semantic logging mean? Semantic logging means that before writing a message you need to define what log messages you will write. Now how do you define and write messages? The answer is the EventSource class. The "System.Diagnostics.Tracing" namespace of the .NET 4.5 Framework provides the EventSource class. See the syntax.

public class MyEventEventSource : EventSource
{
    public class Points
    {
        // code
    }

    public class Tasks
    {
        // code
    }

    [Event(definition...)]
    internal void Task(string message)
    {
        // code
    }

    public static readonly MyEventEventSource Log = new MyEventEventSource();
}

The class, MyEventEventSourcethat extends the EventSource class, contains definitions for all of the events that you want to be able to log in using Event Tracing for Windows (ETW).

Application using the Semantic Logging Application Block

Application block