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

我已更改为在应该解决此问题的数据契约(Contract)上使用 IsReference 属性。但是现在返回的对象是空的! (所有字段都是默认值或空值)。这在我的 ASP.NET 客户端(原始)和我的 Silverlight 客户端中是一样的。

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

最佳答案

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

2- 确保所有需要转移的属性都有一个公共(public)的 getter 和 setter

关于asp.net - DataContract IsReference=true 返回空对象,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/5515122/

10-12 00:01