出现这种错误,先去修改服务器端和客户端的MaxReceivedMessageSize值,如果还报错那么查看你的代码调用了是不是new了一个新的BasicHttpBinding对象,如果是new了新的那么你的webconfig根本就没有被调用,在new的时候要将 <binding name="DataSyncService" 中的name值作为参数传进去,或者是在代码里重新设置MaxReceivedMessageSize值
第一种
DataSyncServiceClient service = new DataSyncServiceClient(new BasicHttpBinding("DataSyncService"), new EndpointAddress(new Uri(con)));
第二种
DataSyncServiceClient service = new DataSyncServiceClient(new BasicHttpBinding(), new EndpointAddress(new Uri(con)));
(service.Endpoint.Binding as BasicHttpBinding).MaxReceivedMessageSize = int.MaxValue;
(service.Endpoint.Binding as BasicHttpBinding).MaxBufferPoolSize = int.MaxValue;(service.Endpoint.Binding as BasicHttpBinding).MaxBufferSize = int.MaxValue;