![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| | |||||||
| | Vista - Readonly collection support in DataContractSerializer? |
| |
| 11-08-2006 | #1 |
| | Readonly collection support in DataContractSerializer? Just getting to grips with the new (to me) DataContractSerializer through WCF and my class is failing to serialize because a [DataMember] doesn't have a setter. But there's a good reason for this - the property is a readonly collection, you know... private List<SomeType> _things = new List<SomeType>(); [DataMember] public List<SomeType> Things { get { return _things; } } The old XmlSerializer used to understand this and play nicely but the DataContract serializer doesn't seem to want to. Any ideas? Am I missing an attribute somewhere? |
| My System Specs |
| 11-08-2006 | #2 |
| | Re: Readonly collection support in DataContractSerializer? You do can continue to use XmlSerializer if it's good for you http://msdn.microsoft.com/msdnmag/is...efault.aspx#S4 Arkady "MrAnon" <josh.twist@gmail.com> wrote in message news:1162992886.697261.198840@i42g2000cwa.googlegroups.com... > Just getting to grips with the new (to me) DataContractSerializer > through WCF and my class is failing to serialize because a [DataMember] > doesn't have a setter. But there's a good reason for this - the > property is a readonly collection, you know... > > private List<SomeType> _things = new List<SomeType>(); > > [DataMember] > public List<SomeType> Things > { > get { return _things; } > } > > The old XmlSerializer used to understand this and play nicely but the > DataContract serializer doesn't seem to want to. > > Any ideas? Am I missing an attribute somewhere? > |
| My System Specs |
| 11-08-2006 | #3 |
| | Re: Readonly collection support in DataContractSerializer? Thanks Arkady, I am aware of that option but I'm wondering if it's possible to configure the DataContract Serializer to be happy with this... Anyone? |
| My System Specs |
| 11-09-2006 | #4 |
| | Re: Readonly collection support in DataContractSerializer? Additionally : you can set empty setter to be it happy ![]() Arkady "MrAnon" <josh.twist@gmail.com> wrote in message news:1163003829.126813.163320@f16g2000cwb.googlegroups.com... > Thanks Arkady, > > I am aware of that option but I'm wondering if it's possible to > configure the DataContract Serializer to be happy with this... > > Anyone? > |
| My System Specs |
| 11-16-2006 | #5 |
| | Re: Readonly collection support in DataContractSerializer? But the serializer will add things to the collection that we ignored... so my collection will always be emtpy ![]() Arkady Frenkel wrote: > Additionally : you can set empty setter to be it happy ![]() > Arkady > > "MrAnon" <josh.twist@gmail.com> wrote in message > news:1163003829.126813.163320@f16g2000cwb.googlegroups.com... > > Thanks Arkady, > > > > I am aware of that option but I'm wondering if it's possible to > > configure the DataContract Serializer to be happy with this... > > > > Anyone? > > |
| My System Specs |
| 11-16-2006 | #6 |
| | Re: Readonly collection support in DataContractSerializer? BTW , you can ask additionally if that documented somewhere on http://forums.microsoft.com/MSDN/Sho...D=118&SiteID=1 Arkady "MrAnon" <josh.twist@gmail.com> wrote in message news:1163677111.476397.14850@k70g2000cwa.googlegroups.com... > But the serializer will add things to the collection that we ignored... > so my collection will always be emtpy ![]() > > > Arkady Frenkel wrote: > >> Additionally : you can set empty setter to be it happy ![]() >> Arkady >> >> "MrAnon" <josh.twist@gmail.com> wrote in message >> news:1163003829.126813.163320@f16g2000cwb.googlegroups.com... >> > Thanks Arkady, >> > >> > I am aware of that option but I'm wondering if it's possible to >> > configure the DataContract Serializer to be happy with this... >> > >> > Anyone? >> > > |
| My System Specs |
| 12-11-2006 | #7 |
| | RE: Readonly collection support in DataContractSerializer? MrAnon, The behavior for DataContractSerializer mentioned below is currently by design. Using an empty setter, as mentioned later in the thread will result in data lost during deserialization. Thanks, Sara "MrAnon" wrote: > Just getting to grips with the new (to me) DataContractSerializer > through WCF and my class is failing to serialize because a [DataMember] > doesn't have a setter. But there's a good reason for this - the > property is a readonly collection, you know... > > private List<SomeType> _things = new List<SomeType>(); > > [DataMember] > public List<SomeType> Things > { > get { return _things; } > } > > The old XmlSerializer used to understand this and play nicely but the > DataContract serializer doesn't seem to want to. > > Any ideas? Am I missing an attribute somewhere? > > |
| My System Specs |
![]() |
| Thread Tools | |
| |
| Similar Threads for: Readonly collection support in DataContractSerializer? | ||||
| Thread | Forum | |||
| Database is readonly | General Discussion | |||
| RE: ReadOnly | Vista networking & sharing | |||
| setting a variable as readonly | PowerShell | |||