解决方案 在返回结果model上加[KnownType(typeof(Dictionary<string, string>))],完整代码:
[DataContract]
[KnownType(typeof(Dictionary<string, string>))]
public class RetJson<T>
{
[DataMember]
public RetJsonHead Head { get; set; }
[DataMember]
public T Body { get; set; }
}
[DataContract]
public class RetJsonHead
{
public RetJsonHead(int errorCode = 0, string errorMessage = null)
{
ErrorCode = errorCode;
ErrorMessage = errorMessage;
}
[DataMember]
public int ErrorCode { get; set; }
[DataMember]
public string ErrorMessage { get; set; }
}
实现:
Model.RetJson<Dictionary<string, string>> IQuoteLibaryService.Delete()
{
var dd = new Model.RetJson<Dictionary<string, string>>();
dd.Body.Add("GetTiluInfoEx", "GetTiluInfoEx");
return dd;
}
接口:
[OperationContract]
RetJson<Dictionary<string, string>> Delete();