【发布时间】:2011-01-14 17:56:22
【问题描述】:
以前有人见过这个异常吗?谷歌或必应的结果绝对很少。
IsValid(object value) has not been implemented by this class.
The preferred entry point is GetValidationResult() and classes should override
IsValid(object value, ValidationContext context).
这是自定义验证器:
public class PriceAttribute : ValidationAttribute
{
public string Id { get; set; }
protected override ValidationResult IsValid(object value, ValidationContext validationContext)
{
//I think this definition for IsValid is in DataAnnotations 4.0
return base.IsValid(value, validationContext);
}
public override bool IsValid(object value)
{
//This I think is the older definition. Not sure why it expects this
return base.IsValid(value);
}
}
谢谢!
【问题讨论】:
-
这是编译器错误还是抛出了运行时异常?如果是这样,你有我们的堆栈跟踪吗?
-
@Steven - 这是一个编译器错误。我认为这与 DataAnnotations 的汇编版本有关?
标签: model-view-controller data-annotations validation