1

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?

abatishchev
  • 98,240
  • 88
  • 296
  • 433
magol
  • 6,135
  • 17
  • 65
  • 120

1 Answers1

5

Does the target still have the desired property in .net 4? There were quite a few API Changes.

Michael Stum
  • 177,530
  • 117
  • 400
  • 535