Asp.net mvc 3 为什么IntegerAttribute不解析ErrorMessageResourceType?

Asp.net mvc 3 为什么IntegerAttribute不解析ErrorMessageResourceType?,asp.net-mvc-3,localization,attributes,data-annotations,Asp.net Mvc 3,Localization,Attributes,Data Annotations,我正在做asp.net MVC3项目,在我的类模型CarModel中,我输入了一个整数属性来验证属性ModelYear,我尝试根据本地化自定义错误消息,我的代码: [Integer(ErrorMessageResourceName = "OnlyNumberValidator", ErrorMessageResourceType = typeof(AddNewCar))] public Nullable<int> ModelYear { get; set; } 但它没有接收我的错误

我正在做asp.net MVC3项目,在我的类模型CarModel中,我输入了一个整数属性来验证属性ModelYear,我尝试根据本地化自定义错误消息,我的代码:

[Integer(ErrorMessageResourceName = "OnlyNumberValidator", ErrorMessageResourceType = typeof(AddNewCar))]
public Nullable<int> ModelYear { get; set; }
但它没有接收我的错误消息,只是显示了默认消息字段ModelYear必须是一个数字


注意:它适用于必需属性

请检查您的参考资料,确保除了Nuget软件包中的DataAnnotationsExtensions之外,您还使用了DataAnnotationsExtensions.Mvc。如果没有特定于Mvc的库,它将产生与您当前体验到的相同的输出。

是的,我使用的是DataAnnotationsExtensions.Mvc