title: How to add an attribute to a property at runtime
body: <pre><code>//Get PropertyDescriptor object for the given property name
  var propDesc = TypeDescriptor.GetProperties(typeof(T))[propName];
  
  //Get FillAttributes methodinfo delegate
  var methodInfo = propDesc.GetType().GetMethods(BindingFlags.Instance | BindingFlags.Public |
                                                        BindingFlags.NonPublic)
      .FirstOrDefault(m =&gt; m.IsFamily || m.IsPublic &amp;&amp; m.Name == "FillAttributes");
  
  //Create Validation attribute
  var attribute = new RequiredAttribute();
  var  attributes= new ValidationAttribute[]{attribute};
  
  //Invoke FillAttribute method
  methodInfo.Invoke(propDesc, new object[] { attributes });
  </code></pre>
  
  <p>Hi I am trying to add Validation attribute at runtime using the above code. However I am getting the below exception:</p>
  
  <blockquote>
    <p>Collection was of a fixed size</p>
  </blockquote>