Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# WCF服务呼叫失败…什么';我的配置文件有什么问题?_C#_Wpf_Wcf_Web Services - Fatal编程技术网

C# WCF服务呼叫失败…什么';我的配置文件有什么问题?

C# WCF服务呼叫失败…什么';我的配置文件有什么问题?,c#,wpf,wcf,web-services,C#,Wpf,Wcf,Web Services,我有一个C#WCF服务,它将一组实例化的.Net对象传递给调用者。工作正常,但是如果我尝试在集合中传递太多对象,则会失败,出现以下异常: {"An error occurred while receiving the HTTP response to http://myserver/MyAppService/MyAppService.svc. This could be due to the service endpoint binding not using the HTTP protocol

我有一个C#WCF服务,它将一组实例化的.Net对象传递给调用者。工作正常,但是如果我尝试在集合中传递太多对象,则会失败,出现以下异常:

{"An error occurred while receiving the HTTP response to http://myserver/MyAppService/MyAppService.svc. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details."}
{"The underlying connection was closed: An unexpected error occurred on a receive."}
{"Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host."}
{"An existing connection was forcibly closed by the remote host"}
它是完全可复制的,并且肯定与集合中的对象数量有关,而不是对象的内容

根据我关于它的另一篇文章,我尝试对客户端app.config文件和服务服务器端web.config文件进行更改。但是,这些更改并没有解决问题,这让我认为可能是我没有正确设置配置文件

下面是我的客户端app.config文件(删除了不相关的内容):


这是我的服务器端web.config文件(删除了不相关的内容):


这些看起来正确吗?如果是这样的话,我在其中任何一个方面都缺少什么可以让这一切顺利进行的东西吗


感谢查看可用的服务日志,它使查找实际问题变得更加容易

首先,将其添加到web.config,然后使用查看器(SvcTraceViewer.exe)查找该文件

对我来说,它位于此处(C:\Program Files(x86)\Microsoft SDK\Windows\v7.0A\Bin)



您是否尝试删除mex端点?

终于找到了。问题是,在服务器端web.config上,行为maxItemsInObjectGraph必须是servicebehavior,而不是endpoint行为。

您是使用WCF服务配置编辑器,还是手动修改这些文件?我在自动创建文件后手动修改了这些文件。配置编辑器未经任何修改就在简单的.config文件上给出错误。其他人是否看到任何可能错误的内容?我建议使用配置编辑器使配置没有错误。我没有遇到过像您所说的基本配置文件有错误的问题。我还将检查服务器上的事件日志以获取更多上下文。最后,尝试在客户端和服务器上设置WSHttpBinding,并使用它而不是Basic。我在这里看到了例外,但不幸的是,除了我已有的信息之外,我没有看到任何其他信息。有什么特别需要我找的吗?
<system.serviceModel>
  <bindings>
    <basicHttpBinding>
      <binding name="BasicHttpBinding_iMyAppService" closeTimeout="00:01:00"
      openTimeout="00:01:00" receiveTimeout="01:00:00" sendTimeout="01:00:00"
      allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
      maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647"
      messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
      useDefaultWebProxy="true">
        <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647"
        maxBytesPerRead="4096" maxNameTableCharCount="2147483647" />
        <security mode="None">
          <transport clientCredentialType="None" proxyCredentialType="None"
          realm="" />
          <message clientCredentialType="UserName" algorithmSuite="Default" />
        </security>
      </binding>
    </basicHttpBinding>
  </bindings>
  <behaviors>
    <endpointBehaviors>
      <behavior name="Behaviors.EndpointBehavior">
        <dataContractSerializer maxItemsInObjectGraph="2147483647" />
      </behavior>
    </endpointBehaviors>
  </behaviors>
  <client>      
    <endpoint address="http://myserver/MyAppService/MyAppService.svc"
    behaviorConfiguration="Behaviors.EndpointBehavior"
    binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_iMyAppService"
    contract="MyAppService.iMyAppService" name="BasicHttpBinding_iMyAppService" />
  </client>
</system.serviceModel>
<system.serviceModel>
  <behaviors>
    <serviceBehaviors>
      <behavior>
        <serviceMetadata httpGetEnabled="true"/>
        <serviceDebug includeExceptionDetailInFaults="true"/>
      </behavior>
    </serviceBehaviors>
    <endpointBehaviors>
      <behavior name="Behaviors.EndpointBehavior">
        <dataContractSerializer maxItemsInObjectGraph="2147483647" />
      </behavior>
    </endpointBehaviors>
  </behaviors>
  <bindings>
    <basicHttpBinding>
      <binding name="BasicHttpBinding_iMyAppService"
             closeTimeout="00:01:00"
      openTimeout="01:00:00" receiveTimeout="01:00:00" sendTimeout="01:00:00"
      allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
      maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647"
        messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
        useDefaultWebProxy="true">
        <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647"
          maxBytesPerRead="4096" maxNameTableCharCount="2147483647" />
        <security mode="None">
          <transport clientCredentialType="None" proxyCredentialType="None"
            realm="" />
          <message clientCredentialType="UserName" algorithmSuite="Default" />
        </security>
      </binding>
    </basicHttpBinding>
  </bindings>
  <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
  <services>
    <service name="MyApp_WCFService.MyAppService">
      <host>
        <baseAddresses>
          <add baseAddress="http://localhost/MyAppService/"/>
        </baseAddresses>
      </host>
      <endpoint address="" behaviorConfiguration="Behaviors.EndpointBehavior" binding="basicHttpBinding" contract="MyApp_WCFService.iMyAppService" bindingConfiguration="BasicHttpBinding_iMyAppService">
        <identity>
          <dns value="localhost"/>
        </identity>
      </endpoint>
      <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
    </service>
  </services>
</system.serviceModel>
<system.webServer>
  <modules runAllManagedModulesForAllRequests="true">
  </modules>
</system.webServer>
<system.diagnostics>
    <sources>
        <source name="System.ServiceModel.MessageLogging" switchValue="Warning, ActivityTracing" >
            <listeners>
                <add name="ServiceModelTraceListener"/>
            </listeners>
        </source>
        <source name="System.ServiceModel" switchValue="Verbose,ActivityTracing">
            <listeners>
                <add name="ServiceModelTraceListener"/>
            </listeners>
        </source>
        <source name="System.Runtime.Serialization" switchValue="Verbose,ActivityTracing">
            <listeners>
                <add name="ServiceModelTraceListener"/>
            </listeners>
        </source>
    </sources>

    <sharedListeners>
        <add initializeData="App_tracelog.svclog" type="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" name="ServiceModelTraceListener" traceOutputOptions="Timestamp"/>
    </sharedListeners>
</system.diagnostics>