I’m having some problems with deserializing an object.
I have following classes:
Metadatastore:
[DataContract]
public class MetadataStore : IEnumerable<ItemMetadata>
{
private List<ItemMetadata> data = new List<ItemMetadata>();
private string folderPath = null;
[DataMember]
public string FilePath
{
// getter and setter
}
[DataMember]
public List<ItemMetadata> Data
{
// getter and setter
}
}
ItemMetadata:
[Serializable()]
public class ItemMetadata
{
// syncid, syncversion, uristring etc..
}
The problem:
I’m transferring a Metadatastore object from my server(which has a wcf service running) to my client by using an output parameter. So serialization/deserialization of this output param is automatically done by wcf I suppose.
This is what happens:
the client calls the service:
service.GetChangeBatch(out metadatastore_object, otherValue);
the server responds correctly (metadatastore_object is filled and serialized successfully -> no errors)
the object I receive on client side though is not correct: the FilePath is filled correctly, but the List Data object contains zero elements! I checked also on the server and the data list contained 2 elements. Another strange thing to note is that it isn’t either null, it’s just a newly created empty list.
Does somebody has some experience with this, I can provide more code if needed.
Thanks in advance. Greets Daan
Use
CollectionDataContractinstead ofDataContract.Here the msdn’s explanation about
CollectionDataContract:http://msdn.microsoft.com/en-us/library/aa347850.aspx