mscorlib.dll中发生了类型为'System.ServiceModel.CommunicationException'的未处理异常 [英] An unhandled exception of type 'System.ServiceModel.CommunicationException' occurred in mscorlib.dll

查看:128
本文介绍了mscorlib.dll中发生了类型为'System.ServiceModel.CommunicationException'的未处理异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我正在使用客户端和服务器模型我的服务器向clinet引发一个事件,并发送List< string> Item.List项包含3000个对象.引发事件时,出现以下错误

其他信息:套接字连接已中止.这可能是由于处理您的消息时出错或远程主机超出了接收超时,或者是潜在的网络资源问题引起的.本地套接字超时为"00:01:00".
请参考我的配置文件.

 Hi All,
        I am using client and server model My server raises an event to clinet and sends List<string> Item.List Item contains 3000 object.When I raise an event I am getting following error

Additional information: The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:01:00'.
please refer my config files.

我的代码适用于数量较少的列表对象(例如30).

My code is working for smaller number of list objects say 30.

------------------------------服务器app.config ------------- --------------------------
<?xml版本="1.0"编码="utf-8"; ?>
<配置>
<!-< system.serviceModel>
<服务>
>
端点
address ="net.tcp://localhost:8001/MyService"
绑定="netTcpBinding"
合约="IMyContract"








</service>->

< system.serviceModel>



服务>

<服务名称="MyPubslisher">

<端点地址="net.tcp://localhost:8001/MyService"
binding ="netTcpBinding"; bindingName ="bindCmdHandler";

合约=``IMyContract''/>

</service>


</services>





; bindings>

< netTcpBinding>


< binding name ="bindCmdHandler''

closetimeout =" 00:30:00"

openTimeout =''00:30:00''


receiveTimeout ="00:30:00''


sendTimeout ="00:30:00''


transactionFlow = ``false''

transferMode =已缓冲"

交易Protocol ="OleTransactions"

hostNameComparisonMode ="StrongWildcard" 100''

maxBufferPoolSize =''524288''


maxBufferSize =''524288''
>

.< readerQuotas maxDepth ="38882"

maxStringContentLength ="524288"

maxArrayLength ="524288"


maxBytesPerRead ="524288" />

< security mode =无">


</security>


</binding>


></netTcpBinding>

</bindings>

</system.serviceModel>
服务>
</system.serviceModel>->
</configuration>

-------------------- -------------------------------------------------- ---------------------
-------------------------- --------------客户端app.config -------------------------------- -
<?xml版本="1.0"编码=< utf-8" ;?
<配置>
< system.serviceModel>
< client>
< endpoint

地址=" net.tcp ://localhost:8001/MyService";
绑定="netTcpBinding";
合约="IMyContract"
/</
br>
closeTimeout ="00:30:00"

openTimeout ="00:30:00"


receiveTimeout ="00:30:00"

sendTimeout ="00:30:00"


transactionFlow ="false" br>

hostNameComparisonMode ="StrongWildcard"


listenBacklog ="100"


maxBufferPoolSize ="524288"
大小
maxConnections ="100"

maxReceivedMessageSize ="524288">


maxArr ayLength ="524288"

maxBytesPerRead ="524288"

maxNameTableCharCount ="524288" />

< security mode =无">


</security>


</binding>


></netTcpBinding>

</bindings>
</system.serviceModel>
</configuration>
-------------------------------------------------- --------------------------------

服务器端program.cs
---- ------------------------------------
static void Main()
{ >> ServiceHost主机=新的ServiceHost(typeof(MyPubslisher));//新的Uri(" http://localhost:8002/") );
host.CloseTimeout = TimeSpan.FromMinutes(10);
host.OpenTimeout = TimeSpan.FromMinutes(20); MyPublisherForm());
host.Close();
}

-------------------------- ---------------------------------

------------------------------ server app.config---------------------------------------
<?xml version = "1.0" encoding = "utf-8" ?>
<configuration>
  <!--<system.serviceModel>
    <services>
 
      <service name = "MyPubslisher">
 
        <endpoint
           address  = "net.tcp://localhost:8001/MyService"
           binding  = "netTcpBinding"
           contract = "IMyContract"
          
            />
 
 
 
      </service>-->
 
  <system.serviceModel>
 
    <services>
 
      <service name="MyPubslisher">
 
        <endpoint address="net.tcp://localhost:8001/MyService"
 
        binding="netTcpBinding"    bindingName="bindCmdHandler"        
 
        contract="IMyContract"/>
 
      </service>
 
    </services>
 
 
 
    <bindings>
 
      <netTcpBinding>
 
        <binding name="bindCmdHandler"
 
        closeTimeout="00:30:00"
 
        openTimeout="00:30:00"
 
        receiveTimeout="00:30:00"
 
        sendTimeout="00:30:00"
 
        transactionFlow="false"
 
        transferMode="Buffered"
 
        transactionProtocol="OleTransactions"
 
        hostNameComparisonMode="StrongWildcard"
 
        listenBacklog="100"
 
        maxBufferPoolSize="524288"
 
        maxBufferSize="524288"
 
        maxConnections="100"
 
        maxReceivedMessageSize="524288">
 
          <readerQuotas maxDepth="38882"
 
          maxStringContentLength="524288"
 
          maxArrayLength="524288"
 
          maxBytesPerRead="524288"
 
          maxNameTableCharCount="524288" />
 
          <security mode="None">
 
          </security>
 
        </binding>
 
 
      </netTcpBinding>
 
    </bindings>
 
  </system.serviceModel>
 
 
 
  <!--</services>
  </system.serviceModel>-->
</configuration>
 
-------------------------------------------------------------------------------------------
----------------------------------------  client app.config   ---------------------------------
<?xml version = "1.0" encoding = "utf-8"?>
<configuration>
  <system.serviceModel>
    <client>
      <endpoint
         address  = "net.tcp://localhost:8001/MyService"
         binding  = "netTcpBinding"
         contract = "IMyContract" 
       />
     
    </client>
    <bindings>
 
      <netTcpBinding>
 
        <binding name="bindCmdHandler"
 
        closeTimeout="00:30:00"
 
        openTimeout="00:30:00"
 
        receiveTimeout="00:30:00"
 
        sendTimeout="00:30:00"
 
        transactionFlow="false"
 
        transferMode="Buffered"
 
        transactionProtocol="OleTransactions"
 
        hostNameComparisonMode="StrongWildcard"
 
        listenBacklog="100"
 
        maxBufferPoolSize="524288"
 
        maxBufferSize="524288"
 
        maxConnections="100"
 
        maxReceivedMessageSize="524288">
 
          <readerQuotas maxDepth="32"
 
          maxStringContentLength="524288"
 
          maxArrayLength="524288"
 
          maxBytesPerRead="524288"
 
          maxNameTableCharCount="524288" />
 
          <security mode="None">
 
          </security>
 
        </binding>
 
 
      </netTcpBinding>
 
    </bindings>
  </system.serviceModel>
</configuration>
 
-------------------------------------------------------------------------------------------
 
server side program.cs
----------------------------------------
 static void Main()
        {
            ServiceHost host = new ServiceHost(typeof(MyPubslisher));// new Uri("http://localhost:8002/"));
            host.CloseTimeout = TimeSpan.FromMinutes(10);
            host.OpenTimeout = TimeSpan.FromMinutes(20);
 
            host.Open();
            Application.Run(new MyPublisherForm());
            host.Close();
        }
 
-----------------------------------------------------------

推荐答案

您的客户端看起来像

Your client looks like

< client>
< endpoint
地址=" net.tcp://localhost:8001/MyService"
绑定="netTcpBinding";
合约="IMyContract"
//>
</client>

<client>
      <endpoint
         address  = "net.tcp://localhost:8001/MyService"
         binding  = "netTcpBinding"
         contract = "IMyContract" 
       />     
</client>

您忘了添加bindingConfiguration,所以我应该像这样:

Your forgot to add bindingConfiguration, so I should look like:

< client>
< endpoint
地址=" net.tcp://localhost:8001/MyService"
绑定="netTcpBinding";
合约="IMyContract"

bindingConfiguration =="bindCmdHandler"
/>
</client>

<client>
      <endpoint
         address  = "net.tcp://localhost:8001/MyService"
         binding  = "netTcpBinding"
         contract = "IMyContract"  
         bindingConfiguration = "bindCmdHandler"
       />     
</client>

如果仍然给您一个CommunicationException,请尝试增加

If it still gives you an CommunicationException, try increasing the limits of 

maxBufferPoolSize
maxBufferSize
maxReceivedMessageSize
maxArrayLength
maxBytesPerRead

maxBufferPoolSize
maxBufferSize
maxReceivedMessageSize
maxArrayLength
maxBytesPerRead


这篇关于mscorlib.dll中发生了类型为'System.ServiceModel.CommunicationException'的未处理异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆