Portable Library in Visual Studio 2012

Topics: Validation Application Block
Dec 19, 2012 at 2:45 PM


Does Enterprise Library VAB 5.0 support the portable class library available in Visual Studio 2012?

I have created a Portable Class Library in Visual Studio 2012 targeting frameworks:
- .NET Framework 4.5
- Silverlight 5

I now want to add validation support for the classes in this library.

Attempt #1:

NuGet package: Enterprise Library 5.0 - Validation Application Block.

Install failed. Rolling back...
Could not install package 'CommonServiceLocator 1.0'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.0,Profile=Profile24', but the package does not contain any assembly references that are compatible with that framework. For more information, contact the package author.

Attempt #2:

Installed "Silverlight Integration Pack - May 2011".
Added Reference to:
- Microsoft.Practices.EnterpriseLibrary.Common.Silverlight.dll
- Microsoft.Practices.EnterpriseLibrary.Validation.Silverlight.dll
- Microsoft.Practices.ServiceLocation.dll

But as soon as I add a validation attribute (e.g. [StringLengthValidator(5)] ) i get this build error:

The type 'System.ComponentModel.DataAnnotations.ValidationAttribute' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.ComponentModel.DataAnnotations, Version=, Culture=neutral, PublicKeyToken=ddd0da4d3e678217'.

Thank you for any input,


Dec 24, 2012 at 7:34 AM

I used approach 2 and I manually added a reference to 'System.ComponentModel.DataAnnotations, Version= (from Silverlight 4 located at C:\Program Files (x86)\Microsoft SDKs\Silverlight\v4.0\Libraries\Client on my machine) and it seems to work.

Randy Levy
Enterprise Library support engineer
Support How-to