title: Reflection and Setting Property?
body: <p>So, I have a object class that is inherited from another class.  However, whenever I try to set the child class with the InvokeMember method using reflection, it says that Method/Member doesn't exist.  Am I missing something?</p>
  
  <pre><code>namespace Group {
      public class Person {
          public Guid PersonId { get; set; }
          public string FirstName { get; set; }
  
          public void Load(NameValueCollection fields) {
               Type classType = this.GetType();
  
               PropertyInfo[] properties = classType.GetProperties();
  
               foreach(PropertyInfo property in properties)
               {
                   for(int x = 0; x &lt; fields.Count; x++)
                   {
                       if (fields.Keys[x] != property.Name) continue;
  
                       classType.InvokeMember(property.Name, BindingFlags.Instance | BindingFlags.SetProperty, Type.DefaultBinder, this, new object[] { fields[x] });
                       break;
                   }
               }
         }
  }
  
  namespace Group {
      public class VIPPerson : Person { }
  }
  </code></pre>
  
  <p>The following code calls the above class:</p>
  
  <pre><code>function someMethod() {
      NameValueCollection collection = new NameValueCollection();
      collection.Add("FirstName", "Mark");
  
      VIPPerson person = new VIPPerson();
      person.Load(collection);
  }
  </code></pre>
  
  <p>Any help why the InvokeMember is throwing an error that says the property doesn't exist?</p>