Exception in ModelBase.ValidatePropertyUsingAnnotations

Topics: Issues / bugs
Mar 28, 2013 at 4:48 PM
Hi,

I have a problem in the method "ValidatePropertyUsingAnnotations" with properties exposed (Expose). Calling the method "ValidateProperty" throws an exception which considerably slows down the first display window.

To solve this problem, I have added a test before calling this method:
if(type.GetProperty(propertyName) != null)
{
   System.ComponentModel.DataAnnotations.Validator.ValidateProperty(value, _dataAnnotationsValidationContext[propertyName]);

    // If succeeded, clear any previous error
    if (_dataAnnotationValidationResults.ContainsKey(propertyName))
    {
         _dataAnnotationValidationResults[propertyName] = null;
    }
}
Can you tell me if my correction is good, and it is possible to include it in a future version ?

Thank you

Kevin
Coordinator
Mar 30, 2013 at 6:13 AM
Interesting fix. Did you try version 3.5? It now also supports non-catel properties (but they are not implemented via expose). I will look into this fix.

See https://catelproject.atlassian.net/browse/CTL-35
Apr 2, 2013 at 2:46 PM
Thank you for your reply,
I tried with version 3.5 and it doesn't work either.