C# WCF:为什么我可以';t向我的Web服务发送对象列表

C# WCF:为什么我可以';t向我的Web服务发送对象列表,c#,list,wcf,C#,List,Wcf,我建立一个对象列表:List 我这样称呼我的Web服务: ServiceGestionClient svc = new ServiceGestionClient(); svc.setNewMandatImage(listMandat); 在我的Web服务中,我有: public void setNewMandatImage(List<Mandat> mi) public void setNewMandatImage(列表mi) 但我有以下错误: Unable to conver

我建立一个对象列表:
List

我这样称呼我的Web服务:

ServiceGestionClient svc = new ServiceGestionClient();
svc.setNewMandatImage(listMandat);
在我的Web服务中,我有:

public void setNewMandatImage(List<Mandat> mi)
public void setNewMandatImage(列表mi)
但我有以下错误:

Unable to convert from list<Mandat> to mandat[]
无法从列表转换为mandat[]

他为什么尝试转换为数组?

原因是WCF将通用列表序列化为一个数组,以便通过网络发送。配置只是告诉svcutil创建一个代理,并为了方便起见将它们转换回公共列表

解决方案:

在添加服务参考工具中设置:

最后,应用此设置生成代理类


如果问题仍然存在,请随时通知我。

只需使用
listMandat.ToArray()
。请参阅:错误源自何处?客户机/服务器?具体在哪里。堆栈跟踪会很有帮助…非常感谢。很有帮助