BindingFlags.IgnoreCase not working for Type.GetProperty()?

You've overwritten the default look-up flags, if you specify new flags you need to provide all the info so that the property can be found. For example: BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance


You need to add BindingFlags.Public | BindingFlags.Instance


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.