DataContractSerializer - change namespace and deserialize file bound to old namespace
问题 I have a data class that is serialized with the DataContractSerializer . The class uses the [DataContract] attribute with no explicit Namespace declaration. As such, the namespace in the resulting xml file is generated based on the namespace of the class. The class basically looks like this: namespace XYZ { [DataContract] public class Data { [DataMember(Order = 1)] public string Prop1 { get; set; } [DataMember(Order = 2)] public int Prop2 { get; set; } } } ...and the resulting xml: <?xml