RangeValidator is not an Attribute Class

Topics: Validation Application Block
Feb 11, 2010 at 7:12 PM
I am getting this error when attempting to add this validator to my method.  Can anyone tell me why and how to fix?  Thanks!
Error 1 'Microsoft.Practices.EnterpriseLibrary.Validation.Validators.RangeValidator' is not an attribute class C:\Visual Studio 2008\Projects\AWS_TMTechServices\AWS_Mirror_Svc_Lib\CPUMonitor.cs 67 70 AWS_Mirror_Svc_Lib
Here is my code.
[Microsoft.Practices.EnterpriseLibrary.Validation.Validators.RangeValidator(0, RangeBoundaryType.Inclusive, 110, RangeBoundaryType.Inclusive)]
public float GetNormalCPUUsage(int TimePeriod)
{
	float activity = 0;
       ...
       return (activity);
}
Feb 12, 2010 at 3:43 AM

Hi,

I cant seem to reproduce this one. Is this a compile time error? What version of ent lib are you using?

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

Feb 12, 2010 at 3:25 PM

This is the most recent download as of yesterday 

Feb 12, 2010 at 11:51 PM

And yes this is a combile time error.

 

Thanks for the help

Feb 15, 2010 at 8:30 AM

Do you mean the beta version of ent lib 5? The one i was trying is in the 4.1 so that maybe the cause why i haven't reproduce the problem. I tried using the beta release and yes, I saw the error that you're describing,

I also saw an error:

Error    3    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=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.   


What I did was add a reference to System.ComponentModel.DataAnnotations.ValidationAttribute , and all the errors are gone.

 

Please try.

 

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com