![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | 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) |
| Guest | Re: Serialization and inheritance 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![]() |
| | #3 (permalink) |
| Guest | 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 | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| ACL - Search directories where inheritance has been broken? | akcorr | PowerShell | 2 | 04-17-2008 08:46 PM |
| Re: Problem with folder layout inheritance | Keith Miller \(MVP\) | Vista file management | 3 | 03-15-2008 02:28 AM |
| WPF Inheritance | Russell Mason | Avalon | 1 | 07-04-2006 10:25 AM |
| Abount inheritance and control... | Miguel Ortiz Falcón | Avalon | 1 | 05-08-2006 08:47 AM |
| How can I alter the dependency property inheritance chain? | Pascal Bourque | Avalon | 4 | 05-01-2006 10:08 AM |