![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
| |
| | #1 (permalink) |
| | Serialization and inheritance On both client and server side I have this DataContract and the communication works fine: [DataContract(Name = "Person", Namespace = "ServiceLibrary")] public class Person { [DataMember] public int Id; [DataMember] public string FirstName; [DataMember] public string LastName; } Now I want to change ONLY client to something like this: [DataContract(Namespace = "ServiceLibrary")] public class PersonBase { [DataMember] public string LastName; } [DataContract(Name = "Person", Namespace = "ServiceLibrary")] public class Person : PersonBase { [DataMember] public int Id; [DataMember] public string FirstName; } I tried with various attributes combination to get the thing working but without success. Is there any documentation on the subject? Does anyone has the idea weather something like this is possible? Thanks, Igor. |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Serialization and inheritance Thanks Juval I got that working, although imho, it is pretty strange that the order of the elements in the message means so much to the formatter. Juval Lowy wrote: > Hello Igor, > > I think the problem you are running into is that the order of the > members has to match. It serializes the base class first, so LastName is > first, unlike Id in the original contract (plain alphabetically). Use > the Order property to force the correct order. > Thanks, > > Juval Lowy. > > > >> On both client and server side I have this DataContract and the >> communication works fine: >> >> [DataContract(Name = "Person", Namespace = "ServiceLibrary")] >> public class Person >> { >> [DataMember] >> public int Id; >> [DataMember] >> public string FirstName; >> [DataMember] >> public string LastName; >> } >> Now I want to change ONLY client to something like this: >> >> [DataContract(Namespace = "ServiceLibrary")] >> public class PersonBase >> { >> [DataMember] >> public string LastName; >> } >> [DataContract(Name = "Person", Namespace = "ServiceLibrary")] >> public class Person : PersonBase >> { >> [DataMember] >> public int Id; >> [DataMember] >> public string FirstName; >> } >> I tried with various attributes combination to get the thing working >> but >> without success. >> Is there any documentation on the subject? >> Does anyone has the idea weather something like this is possible? >> Thanks, >> Igor. > > |
My System Specs![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| ADsSecurity and Inheritance | VB Script | |||
| ACL - Search directories where inheritance has been broken? | PowerShell | |||
| Re: Problem with folder layout inheritance | Vista file management | |||