DataContract IsReference=true returning empty objects

限于喜欢 提交于 2019-12-23 16:14:18

问题


I have a WCF service with cyclic references that I was using the CyclicReferencesAwareAttribute attribute (http://chabster.blogspot.com/2008/02/wcf-cyclic-references-support.html) to solve. However now I want to use the same service with a Silverlight client. Receiving data works well on the Silverlight client with this method, however the CyclicReferencesAwareAttribute attribute does not work on the Silverlight side when I want to send objects back again.

I have changed to use the IsReference property on the data contract which is supposed to get round with this issue. However now the objects that are returned are empty! (All fields are either default or null). This is the same in my ASP.NET client (original) and my Silverlight client.

Has anyone hit is issue before? Here is the attribute. [System.Runtime.Serialization.DataContract(Namespace="http://testnamespace.co.uk/entities", IsReference=true)]


回答1:


1- Make sure that all the properties have the System.Runtime.Serialization.DataMember attribute.

2- Make sure that all properties that need to be transfered have a public getter and setter



来源:https://stackoverflow.com/questions/5515122/datacontract-isreference-true-returning-empty-objects

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!