Adding Application Code
The following procedure explains how to incorporate the Validation Application Block into your application.
To prepare your application
Add a reference to the Validation Application Block assembly. In Visual Studio, right-click your project node in Solution Explorer, and then click Add Reference. 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.
Use the same procedure to set a reference to the following assemblies:
- Microsoft.Practices.EnterpriseLibrary.Common.dll
- Microsoft.Practices.ServiceLocation.dll
- Microsoft.Practices.Unity.dll
- Microsoft.Practices.Unity.Interception.dll
If you are using the ASP.NET, WPF, 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.WPF.dll
- Microsoft.Practices.EnterpriseLibrary.Validation.Integration.WCF.dll
(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;
'Usage Imports Microsoft.Practices.EnterpriseLibrary.Validation Imports Microsoft.Practices.EnterpriseLibrary.Validation.Validators
Note
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.