Search code examples
c#datacontractserializer

DatacontractSerializer for desktop applications


While searching for the DataContractSerialization I have found various articles which mentions that DataContractSerialization is used with WCF. Now I am working on one of desktop application with .net 4.0(not any kind of service). This application have variuos data to serialize.

By looking at the features of DataContractSerialization I want to use DataContractSerialization for my application.

So please tell me whether DataContractSerialization can be used for desktop applications and any guidlines for handling the versioning.


Solution

  • You can use datacontractserializer for desktop applications no problems. As for versioning, you can add new members to an existing data contract, and quite easily handle missing data.

    However, if you want to remove fields or change the meaning of existing fields (e.g. your shoe property "size" used to be a eur size but is now a UK shoesize) then it quickly gets difficult. Then you should create a new contract version. See this question: Simple data file versioning with DataContractSerializer.

    Here is a document from microsoft on versioning strategies