Im trying to use FieldInfo.SetVa lue to set the values of fields in a
class, the class is using reflection on itself to popluate its own
fields. but i keep getting this error.
Object type cannot be converted to target type
here is code
Dim myFieldInfo() As System.Reflecti on.FieldInfo
Dim myType As Type = Me.GetType
' Get the type and fields of FieldInfoClass.
myFieldInfo =
myType.GetField s(Reflection.Bi ndingFlags.NonP ublic Or _
Reflection.Bind ingFlags.Instan ce Or
Reflection.Bind ingFlags.Public )
' Display the field information of FieldInfoClass.
Dim i As Integer
For i = 0 To myFieldInfo.Len gth - 1
Dim customatts() As Object =
myFieldInfo(i). GetCustomAttrib utes(True)
If customatts.Leng th > 0 Then
Dim fm As FieldMember = CType(customatt s(0),
FieldMember)
If htFields.Contai ns(fm.DbFieldNa me) Then
myFieldInfo(i). SetValue(me, htFields(fm.DbF ieldName))
End If
Next i
the error occurs on SetValue