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
12
votes
1 answer

Adding a DataMember to an existing DataContract in WCF

I would like to add a DataMember to one of my DataContracts. I would like to know how existing servers and clients will behave in the presence of a new DataMember if one of the parties isn't updated. I recall there is a way to make the DataMember…
Jader Dias
  • 88,211
  • 155
  • 421
  • 625
12
votes
2 answers

Json parsing F#

r@".NETFramework\v4.0\Profile\Client\System.Runtime.Serialization.dll" open System.Runtime.Serialization open System.Runtime.Serialization.Json [] type geo = { [] t:string …
jlezard
  • 1,417
  • 2
  • 15
  • 32
12
votes
1 answer

InvalidDataContractException is an invalid collection type since it have DataContractAttribute

I have this code: [DataContract] class MyData { private Int32 dato1; [DataMember] public Int32 Dato1 { get { return dato1; } set { dato1 = value; } } public MyData(Int32 dato1) { this.dato1 =…
cls71
  • 177
  • 2
  • 8
12
votes
7 answers

WCF Data Contract and Reference Entity Data?

Soliciting feedback/options/comments regarding a "best" pattern to use for reference data in my services. What do I mean by reference data? Let's use Northwind as an example. An Order is related to a Customer in the database. When I implement my…
Brian
  • 1,383
  • 3
  • 16
  • 30
11
votes
1 answer

How do I pass value to List property while testing my WCF service?

I am testing a WCF service method which accepts a DC type parameter, some of my DC properties are of type List. How do i pass values to that, I tried strings in "", did not accept, Please refer the attached screenshot. AdjReason in the attached…
KeenUser
  • 5,305
  • 14
  • 41
  • 62
11
votes
3 answers

DataContract serialization of property of "Type"

How can I effectively serialize a property of type "Type" in my DataContract attributed class? I'm assuming that Type is a non-serializable Type (wow that's getting silly sounding.) I'm sure that there is a way to do this that meets my needs. …
Firoso
  • 6,647
  • 10
  • 45
  • 91
11
votes
3 answers

Constructor in WCF DataContract not reflected on Client

I need to have some data members get some values when I create an instance of the DataContract on the client. This is not happening using constructors. I have searched through different forums and found we have to use [OnDeserializing] and…
Subhasis
  • 714
  • 3
  • 14
  • 28
11
votes
4 answers

What is best-practice when designing SOA WCF web-services?

Given an operation contract such as: [OperationContract] void Operation(string param1, string param2, int param3); This could be redesigned to: [MessageContract] public class OperationRequest { [MessageBodyMember] public string Param1 {…
Victor
  • 1,627
  • 2
  • 12
  • 16
11
votes
3 answers

Why can't I use WCF DataContract and ISerializable on the same class?

I have a class that I need to be able to serialize to a SQLServer session variable and be available over a WCF Service. I have declared it as follows namespace MyNM { [Serializable] [DataContract(Name = "Foo", Namespace =…
Dave
  • 2,552
  • 5
  • 25
  • 30
11
votes
3 answers

Unable to cast Base class (data contract) to derived class

[DataContract] public class SearchCriteria { [DataMember] public string CountryID { get; set; } } [DataContract] public class CitySearchCriteria: SearchCriteria { [DataMember] public string CityID { get; set; } } I am creating…
Nirman
  • 6,715
  • 19
  • 72
  • 139
11
votes
1 answer

DataContractSerializer: Deserialized object with reference id 'xyz' not found in stream. How to recover data?

I have persisted an array of objects to a file using DataContractSerializer. It has been working fine until recently when I started getting the following message. Deserialized object with reference id '15' not found in stream bei…
paul
  • 13,312
  • 23
  • 81
  • 144
11
votes
1 answer

Why Dispose is being called on DataContract even though the service still refers to it?

I have defined the following DataContract which implements IDisposable: [DataContract] public class RegularFileMetadata : FileMetadataBase, IDisposable { bool _Disposed = false; //note this! //... protected virtual void Dispose(bool…
Nawaz
  • 353,942
  • 115
  • 666
  • 851
10
votes
2 answers

Custom Element Names using the DataContractSerializer on a List of primitives

I'm interested about the best way to go about setting custom element names when using List of primitives with the DataContractSerializer. Let's say I have the following class which contains a List of Strings as a DataMember. [DataContract] public…
medkg15
  • 1,565
  • 15
  • 13
10
votes
1 answer

Custom serialization with DataContractSerializer

I'm currently using wrapper classes for my DataSets ,in order to implement custom serialization. I would like to use DataContractSerializer (more like have to use it) but still support the custom serialization. The problem is that the [DataContract]…
Chen
  • 101
  • 1
  • 1
  • 4
10
votes
3 answers

Is there a way to export an XSD schema from a DataContract

I'm using DataContractSerializer to serialize/deserialize my classes to/from XML. Everything works fine, but at some point I'd like to establish a standard schema for the format of these XML files independent of the actual code. That way if…
Eric Anastas
  • 21,675
  • 38
  • 142
  • 236
1 2
3
53 54