我试图从REST WCF服务返回一个通用的ICollection。以下是可能的吗?WCF WebGet和ICollection <>
[ServiceContract]
public class WebConfigurationManager {
[WebGet]
[OperationContract]
public ICollection<string> GetStrings() {
return new string[] { "A", "B", "C" };
}
}
当我尝试从我的Web浏览器执行此操作时,出现错误。翻翻我的WCF跟踪显示我:
无法序列类型的参数“System.String []”(操作“GetStrings”,合同“WebConfigurationManager”),因为它不是确切类型“System.Collections中.Generic.ICollection`1 [System.String]'在方法签名中,不在已知类型集合中。为了序列化参数,请将类型添加到使用ServiceKnownTypeAttribute的操作的已知类型集合中。