1
J'utilise le code suivant:GetProperty fonctionne dans .NET 3.5, mais pas dans .NET 4
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;
}
Il fonctionne dans .NET 3.5. Mais si je change pour .NET 4, alors mi devient nul. Pourquoi?
Vous avez raison. La propriété a été supprimée dans .net 4. Pas bon – magol
@Magol: C'est le risque de s'appuyer sur des choses privées et/ou sans-papiers - ils peuvent, et changent. – Richard