如何在 WCF 中 return IEnumerable?现有连接被远程主机强行关闭
How to return IEnumerable in WCF ? An existing connection was forcibly closed by the remote host
我尝试了 return WCF 服务中的 IEnumerable
IService1.cs
[OperationContract]
IEnumerable GetAllTasks(string PersonName);
Service1.cs
MyEntities db=new MyEntities ();
private IEnumerable getAllTask;
public IEnumerable GetAllTasks(string PersonName)
{
getAllTask= db.GetAllTaskOfPerson(PersonName).ToList();
return getAllTask;
}
客户
Service.ServiceClient ws=new Service.ServiceClient().ToList();
grid.DataSource=ws.GetAllTasks("John");
grid.DataBind();
我收到此错误:
An existing connection was forcibly closed by the remote host
尝试使您的 IEnumerable 成为强类型集合。在 operationcontract
的签名中使用 Collection<T>
或 List<T>
时,Wcf 表现良好
我尝试了 return WCF 服务中的 IEnumerable
IService1.cs
[OperationContract]
IEnumerable GetAllTasks(string PersonName);
Service1.cs
MyEntities db=new MyEntities ();
private IEnumerable getAllTask;
public IEnumerable GetAllTasks(string PersonName)
{
getAllTask= db.GetAllTaskOfPerson(PersonName).ToList();
return getAllTask;
}
客户
Service.ServiceClient ws=new Service.ServiceClient().ToList();
grid.DataSource=ws.GetAllTasks("John");
grid.DataBind();
我收到此错误:
An existing connection was forcibly closed by the remote host
尝试使您的 IEnumerable 成为强类型集合。在 operationcontract
的签名中使用Collection<T>
或 List<T>
时,Wcf 表现良好