Share via

Referencing Enterprise Library Assemblies

Retired Content

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

The latest Enterprise Library information can be found at the Enterprise Library site.

Before you can build applications that incorporate the Enterprise Library application blocks, you must add references to the application block assemblies and to the Common and ObjectBuilder2 assemblies (if you are using the Unity Integration approach, you must reference the Common and Unity assemblies). This prepares your application to use the Enterprise Library. Take care to select the assemblies that reflect your decision to use the Microsoft strong-named assemblies, non-strong-named assemblies, or a customized set of Enterprise Library assemblies.

To prepare your application

  1. Add a reference to the application block assembly. In Visual Studio, right-click your project node in Solution Explorer, and then click Add References. Click the Browse tab, and then find the location of the application block assembly (the script CopyAssemblies.bat copies all application block assemblies to the bin subdirectory). Select the assembly, and then click OK to add the reference. For example, to reference the Caching Application Block assembly, browse to the bin subdirectory, select the assembly Microsoft.Practices.EnterpriseLibrary.Caching.dll, and then click OK.
  2. Use the same procedure to set a reference to the Enterprise Library Common assembly, Microsoft.Practices.EnterpriseLibrary.Common.dll and to the ObjectBuilder assembly, Microsoft.Practices.ObjectBuilder2.dll.

Enterprise Library Namespaces

All application blocks adhere to the same convention for namespaces. All code for the Enterprise Library is contained under the root namespace, Microsoft.Practices.EnterpriseLibrary.

Each application block is contained in its own namespace under this root. For example, the Security Application Block uses the Microsoft.Practices.EnterpriseLibrary.Security namespace.

Complex application blocks may include sub-namespaces, but only if this is necessary to improve readability. For example, the SQL Server portion of the Data Access Application Block uses the Microsoft.Practices.EnterpriseLibrary.Data.Sql namespace.

To use elements from the application block without fully qualifying the element reference, add using statements (C#) or Imports statements (Visual Basic .NET) to the top of your source code file. For example, to use elements from the Caching Application Block without fully qualifying the element reference, add the following using statements (C#) or Imports statements (Visual Basic) to the top of your source code file.

using Microsoft.Practices.EnterpriseLibrary.Caching;
using Microsoft.Practices.EnterpriseLibrary.Caching.Expirations;
Imports Microsoft.Practices.EnterpriseLibrary.Caching
Imports Microsoft.Practices.EnterpriseLibrary.Caching.Expirations


For Visual Basic projects, you can also use the References page of the Project Designer to manage references and imported namespaces. To access the References page, select a project node in Solution Explorer. On the Project menu, click Properties. When the Project Designer appears, click the References tab.