validation problem using Policy Injection - validation attributes

Topics: Policy Injection Application Block
Jul 2, 2010 at 12:04 PM

validation problem using PolicyInjection on a simple class:


public class TestClass:MarshaByRefObject


private string testfield;


[StringLengthValidator(10,RangeBoundaryType.Inclusive,20,RangeBoundaryType.Inclusive,MessageTemplate="Enter valid string",Ruleset = "RulesetA")]

public string TestField


get{return testfield;}

set{testfield = value;}



Application Code:



TestClass testClass = PolicyInjection.Create<TestClass>();

testClass.TestField  = "";


catch (Exception ex)




assigned empty string to TestField property but no exception is thrown?

any suggestions??


Jul 5, 2010 at 12:14 AM

The ValidationCallHandler attribute should be place in the set accessor, not to the property itself.  This is also answered in this FAQ item.


Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.