Share via

Adding Application Code

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.

The following procedure explains how to incorporate the Validation Application Block into your application.

To prepare your application

  1. Add a reference to the Validation Application Block assembly. In Visual Studio, right-click your project node in Solution Explorer, and then click Add References. Click the Browse tab and find the location of the Microsoft.Practices.EnterpriseLibrary.Validation.dll assembly. Select the assembly, and then click OK to add the reference.

  2. Use the same procedure to set a reference to the Enterprise Library Common assembly, named Microsoft.Practices.EnterpriseLibrary.Common.dll.

  3. Follow the same procedure to set a reference to the ObjectBuilder assembly, Microsoft.Practices.EnterpriseLibrary.ObjectBuilder2.dll.

  4. If you are using the ASP.NET, Windows Forms, or WCF integration assemblies, add one of the following references as appropriate.

    • Microsoft.Practices.EnterpriseLibrary.Validation.Integration.WinForms.dll
    • Microsoft.Practices.EnterpriseLibrary.Validation.Integration.AspNet.dll
    • Microsoft.Practices.EnterpriseLibrary.Validation.Integration.WCF.dll
  5. (Optional) To use elements from the Validation Application Block without fully qualifying the type with the namespace, add the following using statements (C#) or Imports statements (Visual Basic) to the top of your source code file.

    using Microsoft.Practices.EnterpriseLibrary.Validation;
    using Microsoft.Practices.EnterpriseLibrary.Validation.Validators;
    Imports Microsoft.Practices.EnterpriseLibrary.Validation
    Imports Microsoft.Practices.EnterpriseLibrary.Validation.Validators


For Visual Basic projects, you can 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.