Validator.ValidateProperty always throw error and application is exited
-
Hi all, I checked the validation for my form by using DataAnnotations.
[Required(ErrorMessage="User Name is Required")] [StringLength(12,MinimumLength=6,ErrorMessage="User Name must be in between 6 to 12 Characters")] public string UserName { get { return _UserName; } set { Validator.ValidateProperty(value, new ValidationContext(this, null, null) { MemberName="UserName"}); _UserName = value; } }
The error is always throwed at [Validator.ValidateProperty] and applicaton is stopped!! why on my friend's PC is not and the error message is displayed near the textbox normally. The strange is any source code that i got from internet or from my friend's PC is run normally with DataAnotation. But when i clean project and build it again, the application always throw error ( like : value is required ... ) at Validator.ValidateProperty and application is exited ( or stop running ) How could i solve it ?