I use following code:
protected object GetProperty(object target, string fieldName)
{
Type type = target.GetType();
PropertyInfo mi = type.GetProperty(
fieldName, BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.GetProperty);
object obj = mi.GetValue(target, null);
return obj;
}
It works in .NET 3.5. But if I change to .NET 4, then mi becomes null. Why?