Questions tagged [datacontract]

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.

798 questions
4
votes
1 answer

DataContract Serialization of IEnumerable<> backed by 'yield return' statements

Is it possible to serialize an IEnumerable property where the values are backed by 'yield return' statements? If it's possible, how? It not, why? I'm getting a NullReferenceException from the DataContractSerializer whenever I attempt to do so. An…
Caleb
  • 289
  • 3
  • 17
4
votes
2 answers

DataContract and custom set/get to set a DateTime from a string

I need to parse JSON data from a server and make a list of object istances. I'm using DataContract in order to make an association between json dictionary fields and class properties, however I've a problem: one of these fields contains a date in…
danielemm
  • 1,636
  • 1
  • 14
  • 24
4
votes
3 answers

Calculate size of a package(datacontract) that goes over WCF?

Is it possible to calculate the size of a (complexed) object (with dataContract) that I send over WCF? What I need is to calculate the size on both the request and the response objects and I need to do this in a winform application. Could I maybe…
Banshee
  • 15,376
  • 38
  • 128
  • 219
4
votes
1 answer

REST API only sets certain properties of object

I am working on a REST API that I post to using POST and XML as the content. In my WebInvoke method, it seems to only be serializing a few of the properties. For example, I pass FirstName, LastName, Email, Phone, and Address, but it isn't setting…
Geo
  • 292
  • 1
  • 4
  • 12
4
votes
2 answers

Expose object from class library using WCF

I'm using a class library that exposes a few objects. These objects have a couple of properties that hold data my clients need. I'd like to create a WCF service that returns the objects to my clients but I cannot update the class library in order…
Kyle Russell
  • 367
  • 1
  • 4
  • 9
4
votes
3 answers

DataContract + Multi-dimensional Arrays -- Any solution for this?

From MSDN: Combining collection types (having collections of collections) is allowed. Jagged arrays are treated as collections of collections. Multidimensional arrays are not supported. So, if you can't normally serialize a multidimensional…
4
votes
1 answer

Are there any other reasons why I should consider omitting emitting the default value to be a bad practice?

I've worked with WCF for awhile now and in places where both client and server tend to be co-released; that is, new versions have almost always been released at the same time. Interoperability and versioning aren't issues (in this case at…
Kit
  • 20,354
  • 4
  • 60
  • 103
4
votes
1 answer

Enforcing Restritions On DataContracts

Is there any way one can enforce restrictions on values passed in the form of data contracts as parameters to a given WCF Service? For instance, please consider the contrived and certainly non-compilable example of this Vehicle…
DotNetStudent
  • 889
  • 9
  • 24
4
votes
1 answer

Could not get minOccurs="1" maxOccurs="1" for a string type in a DataContract

Below is a DataContract in my WCF service and its respective xsd schema shown in the wsdl file. [Serializable] [XmlRoot(Namespace = "http://www.example.com/l0257/services/mgnt/datatypes/0/1",IsNullable = false)] public partial class…
Kishore Borra
  • 269
  • 3
  • 15
4
votes
2 answers

DataContract with inheritance?

I have a class with a list of objects that is serialized and deserialized: [DataContract] public class Manager { [DataMember] public BigBase[] enemies; } The class with…
michael
  • 65
  • 2
  • 4
4
votes
2 answers

Problem with DataContract and hierarchy on WCF

i have a problem with an object in my wcf project. I have lets say this object: [DataContract(Name="ClassA")] public class Person{ //---attributes--- } [DataContract(Name="ClassB")] public class Men : Person{ //---attributes--- } Where ClassB…
Phoenix_uy
  • 3,173
  • 9
  • 53
  • 100
4
votes
2 answers

What's the practical way of serializing an instance of subclass by using DataContractSerializer?

What's the practical way of serializing an instance of subclass by using DataContractSerializer? For example, here are the data types: [DataContract] public class Car { public Car() { Wheels = new…
4
votes
1 answer

Proxy class not having equals method WCF

I have a class as DataContract in my webservice and it inherit from IEquatable. But my siverlight webservice generated proxy class does not have equals. Can any one tell me why this is happening and is there a way achieve this?
Madhan
  • 260
  • 4
  • 13
4
votes
2 answers

Runtime add DataContract and DataMember to Dynamic Class created using .Net Reflection

I have used .Net Reflection. Emit to create Dynamic Class and its fields. Now when I use Generic List of this dynamic class object in Silverlight enabled WCF service it is giving me an error on the reference side. Service reference does not know…
hitesh agja
  • 83
  • 2
  • 7
4
votes
2 answers

DataContractSerializer not deserializing all variables

I'm trying to deserialize some xml without having the original class that was used to create the object in xml. The class is called ComOpcClientConfiguration. It's succesfully setting the ServerUrl and ServerUrlHda values, but not rest of them... So…
Jean-Bernard Pellerin
  • 12,556
  • 10
  • 57
  • 79