【发布时间】:2015-05-19 08:01:20
【问题描述】:
我有一个用于 WCF 服务的类。
接口定义
[WebGet(ResponseFormat = WebMessageFormat.Json,
UriTemplate = "GetMyStuff/?p={param}",
BodyStyle = WebMessageBodyStyle.Bare)]
MyResponseObject MyMethod(string param);
在我拥有的属性中
public bool IsDecorated {
get {
return !String.IsNullOrEmpty(Decoration);
}
}
导致请求被拒绝加载。
添加后
set { }
成功了。
有什么线索吗?
【问题讨论】:
-
只读属性未序列化。因为当它们被反序列化时,它们将没有 setter。读这个。 stackoverflow.com/questions/13401192/…
-
set{}不会使其成为非只读 -
编译器不关心你是否在里面写了逻辑。它只关心你的属性应该有一个 setter。
标签: c# wcf serialization properties datacontract