I've simplified the code below down to a basic example, but I still cannot get the value to set. When performing the propertyInfo.SetValue(), it will hit a breakpoint on the setter of my Contact object and the value is set correctly in the 'setter.' However, after the SetValue() has executed, the string properties on my projectContact.Contact object have not been changed to "a". Any idea what I could be doing wrong here?
IEnumerable<ProjectContact> contacts = GetContactsByProject(projectId);
foreach (ProjectContact projectContact in contacts)
{
foreach (PropertyInfo propertyInfo in projectContact.Contact.GetType().GetProperties())
{
if (propertyInfo.PropertyType == typeof(string))
{
propertyInfo.SetValue(projectContact.Contact, "a", null);
}
}
}