PRoperty.GetValue "object does not match target type"
Hello la communauté,
J'ai un problème bizarre, bizarre parce que c'est du code qui est censé marché et qui à l'air correct.
LE but de la fonction est de cloner un objet complexe (x variables de type string, integer etc.)
Je vous remets le code, au cas où quelque chose m'échappe...
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
Dim objectType As Type = GetType(MonType)
Dim propertyInfos As System.Reflection.PropertyInfo() = objectType.GetProperties((System.Reflection.BindingFlags.Public Or System.Reflection.BindingFlags.Instance))
Dim propertyInfo As System.Reflection.PropertyInfo = Nothing
Dim value As Object = Nothing
For index As Integer = 0 To propertyInfos.Length - 1
propertyInfo = CType(propertyInfos(index), System.Reflection.PropertyInfo)
If (Not propertyInfo Is Nothing AndAlso propertyInfo.CanRead) Then
value = propertyInfo.GetValue(referenceObject, Nothing)
'Copy the value in the cloned object
propertyInfo.SetValue(clonedObject, value, Nothing)
End If
Next index
Return clonedObject |
et ça plante juste la dessus :
Code:
value = propertyInfo.GetValue(referenceObject, Nothing)
Avant d'arriver sur la ligne, j'ai mis un EspionExpress sur propertyInfo.GetValue(referenceObject, Nothing)
Et même l'espion me retourne ça comme erreur...
Genre, c'est l'appel à la fonction qui plante...
Alors, que c'est censé marché...
Si quelqu'un a une idée, merci d'avance