首页 文章

DataContract IsReference = true返回空对象

提问于
浏览
2

我有一个循环引用的WCF服务,我正在使用CyclicReferencesAwareAttribute属性(http://chabster.blogspot.com/2008/02/wcf-cyclic-references-support.html)来解决 . 但是现在我想在Silverlight客户端上使用相同的服务 . 使用此方法接收数据在Silverlight客户端上运行良好,但是当我想再次发送对象时,CyclicReferencesAwareAttribute属性在Silverlight端不起作用 .

我已经更改为在数据协定上使用IsReference属性,该属性应该可以解决此问题 . 但是现在返回的对象是空的! (所有字段都是默认值或null) . 这在我的ASP.NET客户端(原始)和我的Silverlight客户端中是相同的 .

以前有人打过问题吗?这是属性 . [System.Runtime.Serialization.DataContract(Namespace =“http://testnamespace.co.uk/entities”,IsReference = true)]

1 回答

  • 3

    1-确保所有属性都具有System.Runtime.Serialization.DataMember属性 .

    2-确保需要传输的所有属性都具有公共getter和setter

相关问题