Thanks, this really helped me out in a pinch today. I had audit information saved, but with incorrect casing on the property names. (The auditing is built into a datalayer.) Anyway so I had to add IgnoreCase as a binding flag, but then it still didn't work, till my coworker found this answer. The resulting function:
public static void SetProperty(Object R, string propertyName, object value)
{
Type type = R.GetType();
object result;
result = type.InvokeMember(
propertyName,
BindingFlags.SetProperty |
BindingFlags.IgnoreCase |
BindingFlags.Public |
BindingFlags.Instance,
null,
R,
new object[] { value });
}
This is part of a class I call DotMagic.