1

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.

4 Answers4

1

Yes, DataContractSerializer was written for use by WCF, but it is separate and self-contained, and can be used without using WCF in any way. It is even in a separate assembly.

Marc Gravell
  • 1,026,079
  • 266
  • 2,566
  • 2,900
1

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

Community
  • 1
  • 1
Anders Forsgren
  • 10,827
  • 4
  • 40
  • 77
0

Yes you can use it. Xml Serialization have some kind of disadvantages when you try to serialize dictionaries and lists. But DataContractSerialization Provides all the feature we need.

Rajesh Subramanian
  • 6,400
  • 5
  • 29
  • 42
0

Yes, you can.

Aside from that WCF does not exclude Desktop apps - it can be hosted in a desktop application by using the ServiceHost class.

Ventsyslav Raikov
  • 6,882
  • 1
  • 25
  • 28