C# 基础连接已关闭:该连接因wcf意外关闭
我正在WPF项目中使用WCF服务。我有大量的数据,表中大约有847000条记录。此异常在客户端抛出 在虚拟机中 在App.config中C# 基础连接已关闭:该连接因wcf意外关闭,c#,.net,wpf,wcf,silverlight,C#,.net,Wpf,Wcf,Silverlight,我正在WPF项目中使用WCF服务。我有大量的数据,表中大约有847000条记录。此异常在客户端抛出 在虚拟机中 在App.config中 <?xml version="1.0" encoding="utf-8" ?> <configuration> <system.serviceModel> <bindings> <basicHttpBinding> <binding nam
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IServices" closeTimeout="00:10:00"
openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="clientBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</endpointBehaviors>
</behaviors>
<client>
<endpoint address="http://localhost:7902/WpfStoreService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IServices"
contract="proxy.IServices" name="BasicHttpBinding_IServices" behaviorConfiguration="clientBehavior" />
</client>
</system.serviceModel>
</configuration>
在Web.Config中
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<add name="AdventureWorksLTConnectionString" connectionString="Data Source=.;Initial Catalog=AdventureWorksLT;Integrated Security=True;" />
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IServices" receiveTimeout="00:10:00" sendTimeout="00:10:00" openTimeout="00:10:00" closeTimeout="00:10:00"
maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647"
maxBufferPoolSize="2147483647">
<readerQuotas maxDepth="2147483647"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="214748364"
maxNameTableCharCount="2147483647"/>
<security mode="None"/>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="WpfStore.Services.Services" behaviorConfiguration="debugbehavior">
<endpoint address="" binding="basicHttpBinding" contract="WpfStore.Services.Contracts.IServices" bindingConfiguration="BasicHttpBinding_IServices"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="debugbehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
注:
1.它不能处理大量数据。在本例中,表中有大约847000条记录。它可以完美地处理小数据(大约5000-6000条记录)。
2.我调试了它,并将从SQL server检索到的所有记录保存到DAL中;从客户端调用此服务函数后,此异常会在5-10秒内出现。我刚刚在代码中添加了这一行
System.Net.ServicePointManager.Expect100Continue = false;
发现
希望这能对您有所帮助。我刚刚在代码中添加了这一行
System.Net.ServicePointManager.Expect100Continue = false;
发现
希望这能对您有所帮助。您真的要通过网络发送847000条记录吗?也许你应该考虑使用分页?我只是测试了,它没有工作7000记录tooouy你不跟踪它。大多数此类问题都可以通过跟踪来解决。您的连接似乎已断开。实际上,您打算接收多少条通话记录?7000似乎也很多。我很抱歉这样说,但你应该考虑至少使用一种技术来缩小交通。您可以使用分页、过滤或类似的功能。你必须处理你工作的局限性。限制可能不仅仅来自wcf,也可能来自IIS、代理或其他。你真的要通过网络发送847000条记录吗?也许你应该考虑使用分页?我只是测试了,它没有工作7000记录tooouy你不跟踪它。大多数此类问题都可以通过跟踪来解决。您的连接似乎已断开。实际上,您打算接收多少条通话记录?7000似乎也很多。我很抱歉这样说,但你应该考虑至少使用一种技术来缩小交通。您可以使用分页、过滤或类似的功能。你必须处理你工作的局限性。限制可能不仅仅来自wcf,也可能来自IIS、代理或其他方面。