A data contract is a formal agreement between a service and a client that abstractly describes the data to be exchanged. A data contract precisely defines, for each parameter or return type, what data is serialized to be exchanged.
Questions tagged [datacontract]
798 questions
10
votes
1 answer
Enum.ToString() that abides EnumMemberAnnotation
I have an enum annotated with EnumMember to facilitate JSON.NET serialization similar to the following:
[DataContract]
[JsonConverter(typeof(StringEnumConverter))]
public enum Status
{
[EnumMember(Value = "NOT_ADMITTED")]
NotAdmitted,
…

HolySamosa
- 9,011
- 14
- 69
- 102
9
votes
1 answer
How to use Custom Serialization or Deserialization in WCF to force a new instance on every property of a datacontact ?
I have a datacontact with many members that has a custom class
I would like to force a new instance if the property is null on deserialization.
is there a way to do that?

Fredou
- 19,848
- 10
- 58
- 113
9
votes
5 answers
WCF contract changes that affect clients
I was curious if someone could outline which types of WCF contract (interface) changes on the server side would break a client trying to send in a message, and why. I believe WCF can handle certain discrepancies, but I'm not sure exactly what you…

Andy White
- 86,444
- 48
- 176
- 211
9
votes
3 answers
Mark deprecated fields in WCF contract
I have a wcf contract that works with client v1.
Now I'm working on service v2, and i want to mark some of the fields as deprecated, So client v1 will see and use them, and client v2 will ignore them.
Are there any best practices for this issue?…

Adibe7
- 3,469
- 7
- 30
- 36
9
votes
2 answers
Portable / Interoperable WCF Contracts
I was wondering if anybody out there had some good tips/dos and don'ts for designing WCF contracts with a mind for web-service interoperability, both in terms of older Microsoft web service technologies (e.g. WSE) and non-Microsoft technologies…

Randolpho
- 55,384
- 17
- 145
- 179
9
votes
2 answers
Confused about how to use JSON in C#
The answer to just about every single question about using C# with JSON seems to be "use JSON.NET", but that's not the answer I'm looking for.
The reason I say that is, from everything I've been able to read in the documentation, JSON.NET is…

SelAromDotNet
- 4,715
- 5
- 37
- 59
9
votes
2 answers
Client WCF DataContract has empty/null values from service
I have a simple WCF service that returns the time from the server. I've confirmed that data is being sent by checking with Fiddler. Here's the result object xml that my service sends.

Matt
- 6,264
- 10
- 54
- 82
9
votes
4 answers
c# - DataContract Serialization - Base Classes, Inheritance and Overrides
Good day everyone,
I'm an independent game developer who has, in the past, primarily worked with XNA and, at the other extreme, commercial toolsets. The reach of XNA is pretty limited, however, and I'm building a cross-platform abstraction layer to…

Nathan Runge
- 303
- 2
- 10
8
votes
1 answer
Does ContentResolver notifyChange method notifies also detail Uri's?
During applying data I use notifyChange with an Uri.
Let's say I notify content://com.package.my/items.
I have also detail Activity that displays data from content://com.package.my/items/1.
Does notifying 'general' Uri results also in 'detail' Uri…

pixel
- 24,905
- 36
- 149
- 251
8
votes
3 answers
What does it mean to put DataMemberAttribute on interface member?
What does it mean to put a DataMemberAttribute on an interface member?
How does this affect derived classes?

Adibe7
- 3,469
- 7
- 30
- 36
8
votes
3 answers
What is the advantage of using DataContractAttribute over SerializableAttribute?
I have found that my WCF services work normally when the data types involved doesn't have the [DataContract], but the [Serializable] instead.
But all the WCF tutorials shows the first one instead of the latter. Why?

Jader Dias
- 88,211
- 155
- 421
- 625
8
votes
4 answers
DataContracts with behavior
How bad is it? I have read countless articles and never created abstract DataContracts with behavior before, but it seems that doing so will solve an issue I am having that will prevent me from creating factories everywhere to determine a subclass…

user24985
- 765
- 8
- 12
8
votes
5 answers
Persist a DataContract as XML in a database
I'm working on a kind of "store and forward" application for WCF services. I want to save the message in a database as a raw XML blob, as XElement. I'm having a bit of trouble converting the datacontract into the XElement type I need for the…

Robert
- 2,964
- 1
- 18
- 16
7
votes
3 answers
WCF - Instantiating an object in DataContract constructor
I have two classes as below:
[DataContract]
public class Address
{
[DataMember]
public string Line1
[DataMember]
public string Line2
[DataMember]
public string City
[DataMember]
public string State
[DataMember]
…

Asdfg
- 11,362
- 24
- 98
- 175
7
votes
1 answer
How to make code contracts work with deserialization of data contracts?
I have written a ContractInvariantMethod for a data contract class, and everything works great on the client side, however when an object of this type is sent to my service, and the Data Contract Deserializer tries to deserialize it, code contract…

Arash
- 203
- 1
- 8