title: Cannot apply indexing with [] to an expression of type 'System.Web.Mvc.IValueProvider'
body: <p>I am converting an ASP.NET MVC application to ASP.NET MVC 2, and I get the following error:</p>
  
  <blockquote>
    <p>Cannot apply indexing with [] to an expression of type 'System.Web.Mvc.IValueProvider'</p>
  </blockquote>
  
  <p>Here is the code:</p>
  
  <pre><code>public static void AddRuleViolation(this ModelStateDictionary modelState,
                                      RuleViolation error, 
                                      FormCollection collection)
  {
      modelState.AddModelError(error.PropertyName, error.ErrorMessage);
      modelState.SetModelValue(error.PropertyName, 
                               collection.ToValueProvider()[error.PropertyName]);
  }
  </code></pre>
  
  <p>How can this be remedied?</p>