1
有沒有人看到過此異常? Google或Bing的結果絕對非常少。DataAnnotations中的自定義驗證器屬性異常
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 2010-08-29 15:40:28
@Steven - 這是一個編譯器錯誤。我認爲它與DataAnnotations的彙編版本有關? – DotnetDude 2010-08-30 15:35:11