Been using a Copy method with this code in it in various places in previous projects (to deal with objects that have same named properties but do not derive from a common ba
Try:
toProperty.SetValue(toObj,fromValue,null);
You are trying to pass in the property (toProperty
) as the target object, instead of toObj
. For info, if you are doing lots of this, maybe consider HyperDescriptor, which can vastly reduce the reflection cost.
Should be
toProperty.SetValue(toObj,fromValue,null);