I have two similar[all attributes are same.] structures within different namespaces.
Now when i try to copy values between the objects of these structures i am getti
I ran into this same problem when consuming multiple web services from an external provider through WCF. There is a very large tree of nested objects, which is just painful for doing mapping between classes, especially since this tree has several instances of holding an abstract base class as a member. Since these classes are all defined with the XML serialization attributes needed to transmit to a web service, I opted to use the serializer to do the conversion for me.
TOutput ConvertEquivalentTypes(TInput structure)
where TInput : class
where TOutput : class
{
TOutput result = null;
using (Stream data = new MemoryStream())
{
new XmlSerializer(typeof(TInput)).Serialize(data, structure);
data.Seek(0, SeekOrigin.Begin);
result = (TOutput)new XmlSerializer(typeof(TOutput)).Deserialize(data);
}
return result;
}