PropertyInfo error

  • Thread starter Thread starter Enrico Angkawijaya
  • Start date Start date
E

Enrico Angkawijaya

I receive this error message:

"Object type cannot be converted to target type."

while executing this line:

propertyInfo.SetValue( _Object, x.Value, null)

------------------------

x.Value is of type Int32, while property is of type
string. Please send me email with the solution if
possible.

Sincerely,

Enrico
 
well, the message says it all. You are trying to assign an
Int32 to a String which is not a legal operation.
Reflection will not convert an int to a string for you so
you'll have to do it yourself. A trivial call to ToString
should fix your problem.
propertyInfo.SetValue( _Object, x.Value.ToString(), null)

dario
 
Back
Top