Getting Started with Enterprise Library

Exclusive offer: get 50% off this eBook here
Microsoft Enterprise Library 5.0

Microsoft Enterprise Library 5.0 — Save 50%

Develop Enterprise applications using reusable software components of Microsoft Enterprise Library 5.0 with this book and eBook

£18.99    £9.50
by Sachin Joshi | November 2010 | Enterprise Articles Microsoft

While developing enterprise-scale applications, developers often find themselves focusing on mundane and repeated tasks generally referred to as cross-cutting concerns: tasks such as writing repeated data access code, logging exceptions, handling and managing exceptions, caching data, validating user input, and so on. Although these tasks are important, developers often spend a lot of time implementing and debugging these cross-cutting concerns rather than channeling their efforts towards the core business requirements of customers.

In this article by Sachin Joshi, author of Microsoft Enterprise Library 5.0, you will:

  • Receive an overview of Enterprise Library
  • Receive a brief introduction to functional application blocks
  • Learn about the dependencies between the functional application blocks
  • Learn the system requirements
  • Learn to install Enterprise Library

 

Microsoft Enterprise Library 5.0

Microsoft Enterprise Library 5.0

Develop Enterprise applications using reusable software components of Microsoft Enterprise Library 5.0

  • Develop Enterprise Applications using the Enterprise Library Application Blocks
  • Set up the initial infrastructure configuration of the Application Blocks using the configuration editor
  • A step-by-step tutorial to gradually configure each Application Block and implement its functions to develop the required Enterprise Application

 

        Read more about this book      

Introducing Enterprise Library

Enterprise Library (EntLib) is a collection of reusable software components or application blocks designed to assist software developers with common enterprise development challenges. Each application block addresses a specific cross-cutting concern and provides highly configurable features, which results in higher developer productivity. EntLib is implemented and provided by Microsoft patterns & practices group, a dedicated team of professionals who work on solving these cross-cutting concerns with active participation from the developer community. This is an open source project and thus freely available under the Microsoft Public License (Ms-PL) at the CodePlex open source community site (http://entlib.codeplex.com), basically granting us a royalty-free copyright license to reproduce its contribution, build derivative works, and distribute them.

More information can be found at the Enterprise Library community site http://www.codeplex.com/entlib.

Enterprise Library consists of nine application blocks; two are concerned with wiring up stuff together and the remaining seven are functional application blocks. The following is the complete list of application blocks; these are briefly discussed in the next sections.

  • Wiring Blocks
    • Unity Dependency Injection
    • Policy Injection Application Block
  • Functional Blocks
    • Data Access Application Block
    • Logging Application Block
    • Exception Handling Application Block
    • Caching Application Block
    • Validation Application Block
    • Security Application Block
    • Cryptography Application Block

Wiring Application Blocks

Wiring blocks provides mechanisms to build highly flexible, loosely coupled, and maintainable systems. These blocks are mainly about wiring or plugging together different functionalities. The following two blocks fall under this category:

  • Unity Dependency Injection
  • Policy Injection Application Block

Unity Application Block

The Unity Application Block is a lightweight, flexible, and extensible dependency injection container that supports interception and various injection mechanisms such as constructor, property, and method call injection. The Unity Block is a standalone open source project, which can be leveraged in our application. This block allows us to develop loosely coupled, maintainable, and testable applications. Enterprise Library leverages this block for wiring the con? gured objects. More information on the Unity block is available at http://unity.codeplex.com.

Policy Injection Application Block

The Policy Injection Application Block is included in this release of Enterprise Library for backwards compatibility and policy injection is implemented using the Unity interception mechanism. This block provides a mechanism to change object behavior by inserting code between the client and the target object without modifying the code of the target object.

Functional Application Blocks

Enterprise Library consists of the following functional application blocks, which can be used individually or can be grouped together to address a specific cross-cutting concern.

  • Data Access Application Block
  • Logging Application Block
  • Exception Handling Application Block
  • Caching Application Block
  • Validation Application Block
  • Security Application Block
  • Cryptography Application Block

Data Access Application Block

Developing an application that stores/retrieves data in/from some kind of a relational database is quite common; this involves performing CRUD (Create, Read, Update, Delete) operations on the database by executing T-SQL or stored procedure commands. But we often end up writing the plumbing code over and over again to perform these operations: plumbing code such as creating a connection object, opening and closing a connection, parameter caching, and so on.

The following are the key benefits of the Data Access block:

  • The Data Access Application Block (DAAB) abstracts developers from the underlying database technology by providing a common interface to perform database operations.
  • DAAB also takes care of the ordinary tasks like creating a connection object, opening and closing a connection, parameter caching, and so on.
  • It helps in bringing consistency to the application and allows changing of database type by modifying the configuration.

Logging Application Block

Logging is an essential activity, which is required to understand what's happening behind the scene while the application is running. This is especially helpful in identifying issues and tracing the source of the problem without debugging. The Logging Application Block provides a very simple, flexible, standard, and consistent way to log messages. Administrators have the power to change the log destination (file, database, e-mail, and so on), modify message format, decide on which category is turned on/off, and so on.

Exception Handling Application Block

Handling exceptions appropriately and allowing the user to either continue or exit gracefully is essential for any application to avoid user frustration. The Exception Handling Application Block adapts the policy-driven approach to allow developers/administrators to define how to handle exceptions.

The following are the key benefits of the Exception Handling Block:

  • It provides the ability to log exception messages using the Logging Application Block.
  • It provides a mechanism to replace the original exception with another exception, which prevents disclosure of sensitive information.
  • It provides mechanism to wrap the original exception inside another exception to maintain the contextual information.

Caching Application Block

Caching in general is a good practice for data that has a long life span; caching is recommended if the possibility of data being changed at the source is low and the change doesn't have significant impact on the application. The Caching Application Block allows us to cache data locally in our application; it also gives us the flexibility to cache the data in-memory, in a database or in an isolated storage.

Validation Application Block

The Validation Application Block (VAB) provides various mechanisms to validate user inputs. As a rule of thumb always assume user input is not valid unless proven to be valid. The Validation block allows us to perform validation in three different ways; we can use configuration, attributes, or code to provide validation rules. Additionally it also includes adapters specifically targeting ASP.NET, Windows Forms, and Windows Communication Foundation (WCF).

Security Application Block

The Security Application Block simplifies authorization based on rules and provides caching of the user's authorization and authentication data. Authorization can be done against Microsoft Active Directory Service, Authorization Manager (AzMan) , Active Directory Application Mode (ADAM), and Custom Authorization Provider. Decoupling of the authorization code from the authorization provider allows administrators to change the provider in the configuration without changing the code.

Cryptography Application Block

The Cryptography Application Block provides a common API to perform basic cryptography operations without inclining towards any specific cryptography provider and the provider is configurable. Using this application block we can perform encryption/decryption, hashing, & validate whether the hash matches some text.

Microsoft Enterprise Library 5.0 Develop Enterprise applications using reusable software components of Microsoft Enterprise Library 5.0 with this book and eBook
Published: November 2010
eBook Price: £18.99
Book Price: £30.99
See more
Select your format and quantity:
        Read more about this book      

Functional Application Block Dependency

Several functional application blocks provide features that depends on other blocks; these dependencies are listed below.

Application Block Dependencies Condition
Logging Application Block Data Access Application Block If the messages have to be logged in database.
Exceptional Handling Application Block Logging Application Block. If exception information has to be logged.
Data Access Application Block. If exception information has to be logged to database.
Caching Application Block Data Access Application Block. If data has to be cached in database.
Cryptography Application Block. If cached data has to be encrypted.
Security Application Block Caching Application Block. If credentials have to be cached.
Cryptography Application Block. If cached credentials has to be encrypted.
Data Access Application Block. If credentials have to be cached in database.

Following is the graphical representation of the dependencies between the functional application blocks:

Microsoft Enterprise Library 5.0

Except the Validation block, all other application blocks are dependent on other blocks to provide additional features that are part of the respective application blocks. For example, the Exception Handling block is dependent on the Logging block to provide message logging functionality; additionally the Data Access block is also required if the message needs to be logged in database.

System requirements

Minimum requirements for Enterprise Library core features and the configuration tool are given below.

  • Supported Architectures: x86 and x64
  • Operating System:
    • Microsoft Windows® 7 Professional, Enterprise or Ultimate
    • Windows Server 2003 R2
    • Windows Server 2008 with Service Pack 2
    • Windows Server 2008 R2.
    • Windows Vista with Service Pack 2
  • Microsoft .NET Framework 3.5 with Service Pack 1 or Microsoft .NET Framework 4.0
  • Recommended Development Environment: Any of the following development systems:
    • Microsoft Visual Studio® 2008 Development System with Service Pack 1 (any edition)
    • Microsoft Visual Studio® 2010 Development System (any edition)
  • Required for Data Access Application Block: A database server running a database that is supported by a .NET Framework 3.5 with Service Pack 1 or .NET Framework 4.0 data provider; data providers for OLE DB or ODBC are also supported. Below is the list for reference:
    • SQL Server 2000 or later
    • SQL Server 2005 Compact Edition
    • Oracle 9i or later
  • Required for Logging Application Block: While using the Message Queuing (MSMQ) Trace Listener to store log messages, you need the Microsoft Message Queuing (MSMQ) components installed. Access to a database server is required to store log messages to database while using the Database Trace Listener. Access to an SMTP server is required to send e-mail, while using the E-mail Trace Listener to e-mail log messages.
  • Unit Testing Requirements: To run the unit tests provided as part of the Enterprise Library source code installation we require the following:
    • Microsoft Visual Studio 2008 Professional or Visual Studio 2008 Team Edition or Visual Studio 2010 Premium or Visual Studio 2010 Professional, or Visual Studio 2010 Ultimate edition
    • Moq v3.1 assemblies, which can be downloaded from http://code.google.com/p/moq/

Installing Enterprise Library

Before we start exploring the individual application blocks, let us download and install Enterprise Library first. We can download the latest release of the Enterprise Library available at http://msdn.microsoft.com/entlib/ from MSDN site; alternatively the download link is also available on the home page of the community site at http://entlib.codeplex.com. Click on the link Enterprise Library 5.0 - April 2010 from the list of active releases and download the Microsoft Installer (MSI) package file from the download section. Now follow the steps given below to install the library. It is recommended to install the features given below.

Enterprise Library Binaries

This section provides options to selectively install specific application blocks; it is recommended that you install all the application blocks to avoid running the installer multiple times to add other blocks.

Configuration Editor for Visual Studio

Visual Studio integration of the configuration editor helps us in editing Enterprise Library configuration settings from within the development environment. This comes quite handy instead of switching between the standalone configuration editor and Visual studio IDE.

Source Code of Enterprise Library

It is recommended to install the source code of Enterprise Library; the source code gives lot of insight in to the how each application is implemented and the best practices adopted by the Enterprise Library team.

  1. Double-click the installation file to run Microsoft Enterprise Library 5.0 Setup. The following screenshot with the welcome message will be loaded; click Next to move to the next step of the wizard.

    Microsoft Enterprise Library 5.0

  2. The End-User License Agreement screen is displayed as shown in the following screenshot. It is important and a good practice to read and fully understand the license agreement of any software we use to develop applications. Once we are satisfied with the license terms, we may click Next to move forward to the next installation step.

    Microsoft Enterprise Library 5.0

  3. The following step in the installation wizard displays the system requirements and comes in quite handy to verify whether the system satisfies the minimum requirements. Click Next to move to the next installation step.

    Microsoft Enterprise Library 5.0

  4. Once we click Next we are presented with a feature selection screen as shown in the following screenshot. The installer provides control over installation of the binaries of each individual application block; for the purposes of this demonstration we will install all the features.

    Microsoft Enterprise Library 5.0

  5. Once we click Next, we will be presented with the Ready to install Microsoft Enterprise Library 5.0 screen as shown in the following screenshot. Clicking on the Install button will initiate the installation process.

    Microsoft Enterprise Library 5.0

  6. After the installation is completed the following screen will be shown; we may install the source code of Enterprise Library by selecting the checkbox Launch Microsoft Enterprise Library 5.0 Source Installer and clicking on the Finish button. Provide the appropriate install location for the source code and the installer will copy the source code and additionally build the assemblies if we choose.

    Microsoft Enterprise Library 5.0

Summary

In this article we got introduced to the Enterprise Library and explored various application blocks: the Unity, Policy Injection, Data Access, Logging, Exception Handling, Caching, Validation, Security, and Cryptography blocks. We discussed the dependencies between the functional application blocks. We understood the system requirements and explored the installation steps of Enterprise Library.

Microsoft Enterprise Library 5.0 Develop Enterprise applications using reusable software components of Microsoft Enterprise Library 5.0 with this book and eBook
Published: November 2010
eBook Price: £18.99
Book Price: £30.99
See more
Select your format and quantity:

About the Author :


Sachin Joshi

Sachin Joshi holds a Master's Degree in Computer Applications and a Bachelor's Degree in Business Administration; he is a Microsoft Certified Professional Developer in ASP.NET and Microsoft Certified Technology Specialist in WCF and .NET 3.5 Windows. He has over 5 years of industry experience developing enterprise applications with Microsoft .NET and related technologies. Sachin was performing a juggling act between his college degree and running his own optical business for around 5 years before joining the IT industry.

Sachin is currently working as a Consultant in a reputed software company in Hyderabad, India. He has several years of experience in designing and architecting solutions for various domains and he has been involved with several complex engagements. His technical strengths include C, C++, C#, VB.NET, Microsoft .NET, AJAX, Design Patterns, SQL Server, JavaScript, and more. His current passion is Vala (http://live.gnome.org/Vala) a new C#-like programming language with the power of C.

Sachin blogs at http://fuzzydev.com and spends most of his time reading books and playing with different technologies. When not at work, Sachin spends time with his family, watching movies and playing video games. He and his wife have not only pledged but are working towards spreading awareness of the noble cause of organ donation. Sachin has a dream of opening a library for students who are economically disadvantaged, to enable them to grow. In the technology arena, Sachin is currently working on an open source project code named Apocalypse – lifting of the veil, a CMS based on ASP.NET 4.0.

Books From Packt


Microsoft Dynamics NAV 2009 Application Design
Microsoft Dynamics NAV 2009 Application Design

Microsoft Silverlight 4 Business Application Development: Beginner’s Guide
Microsoft Silverlight 4 Business Application Development: Beginner’s Guide

Microsoft Dynamics NAV 2009 Programming Cookbook
Microsoft Dynamics NAV 2009 Programming Cookbook

Application Development for IBM WebSphere Process Server 7 and Enterprise Service Bus 7
Application Development for IBM WebSphere Process Server 7 and Enterprise Service Bus 7

Microsoft Azure: Enterprise Application Development
Microsoft Azure: Enterprise Application Development

IBM Lotus Sametime 8 Essentials: A User's Guide
IBM Lotus Sametime 8 Essentials: A User's Guide

Microsoft Windows Workflow Foundation 4.0 Cookbook
Microsoft Windows Workflow Foundation 4.0 Cookbook

Applied Architecture Patterns on the Microsoft Platform
Applied Architecture Patterns on the Microsoft Platform


Code Download and Errata
Packt Anytime, Anywhere
Register Books
Print Upgrades
eBook Downloads
Video Support
Contact Us
Awards Voting Nominations Previous Winners
Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
Resources
Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software