Wednesday, 12 January 2011

How to Copy and Object with Reflection

If you need to copy an object then one way of doing it is with reflection. This is useful if a new property is added to a class and you dont want to remember to update the copy function with the new field.


  1. I've got exeption
    Message = "'System.Dynamic.ExpandoObject' does not contain a definition for 'name'"

    1. Hi,
      Just did a bit of research and it appears reflection and dynamic objects dont play too well together.

      I found this post on stack overflow which may help;

      I wrote the code in .net 2.0 so things may have changed since then. Hopefully the Stack Overflow post will point you in the right direction.