今天通过WCF连接数据库拉取500条数据报出这个错误,百度问题发现大部分解决办法都是修改App.config的’ServiceModel`参数,如下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| <bindings> <basicHttpBinding> <binding name="webIn" sendTimeout="00:30:00" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" transferMode="Streamed"> <readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/> <security mode="None"/> </binding>
</basicHttpBinding> <netTcpBinding> <binding name="NetTcpBinding_IMysqlInfo" transferMode="Streamed" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"> <security mode="None"> </security> </binding> </netTcpBinding> </bindings>
|
再修改完这个的时候发现还是报错,于是检查我的启动项
1
| public Post() => _mysqlService = ChannelFactory<IMysqlInfo>.CreateChannel(new BasicHttpBinding(),new EndpointAddress("http://localhost:8084/MySqlInfo.svc") );
|
觉得应该是初始化WCF之后,会将配置文件中的内容忽视,所以依旧报错,如果需要解决错误只需要降配置加到初始化中即可
1 2 3 4 5 6 7 8 9
| public Post() => _mysqlService = ChannelFactory<IMysqlInfo>.CreateChannel(new BasicHttpBinding() { MaxBufferPoolSize = 2147483647, MaxReceivedMessageSize = 2147483647, MaxBufferSize = 2147483647 },new EndpointAddress("http://localhost:8084/MySqlInfo.svc") );
|
这样的话就可以解决依旧报错的问题