Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
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.

Go Back   Vista Forums > Misc Newsgroups > Indigo

Vista - Serialization and inheritance

 
 
Old 03-04-2006   #1 (permalink)
ianic


 
 

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 SpecsSystem Spec
Old 03-04-2006   #2 (permalink)
ianic


 
 

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 SpecsSystem Spec
 

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


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46