public List<dynamic> GetDynamicResult()
{
List<dynamic> lstDynamic = new List<dynamic>();
lstDynamic.Add(new { ID = "1", Name = "ABC" });
lstDynamic.Add(new { ID = "1", Name = "XYZ" });
return lstDynamic;
}
当我将列表从WCF返回到ASP.NET Web App时使用
List<dynamic> lstDynamic = objClient.GetDynamicResult();
我收到此错误:The underlying connection was closed: The connection was closed unexpectedly
答案 0 :(得分:2)
WCF需要定义通过有线发送的DataContract(使用序列化)。使用动态类型与此冲突。您可以使用字符串组合与(反)序列化。