WPF应用程序不更新WCF服务的超时绑定信息

时间:2014-01-15 12:57:39

标签: c# wpf wcf

我有一个包含WCF服务,Windows服务(托管它)和使用它的WPF应用程序的解决方案。我有一个“数据访问dll”,我正在引用该服务。当我搜索服务的解决方案时,它找到它并引用它而没有任何问题,它还为它生成app.config文件。

我遇到的问题是,绑定信息并非全部更新。我的服务配置了超时,这些超时未在本地app.config文件中生成/更新。我只需手动添加它就可以解决它并且工作正常;但是,我希望能够自动更新它们。

这是服务绑定的配置:

<bindings>
      <netTcpBinding>
        <binding name="StreamingBinding" receiveTimeout="00:15:00" sendTimeout="00:15:00"
          transferMode="Streamed" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
          <security mode="None" />
        </binding>
      </netTcpBinding>
    </bindings>

这是我引用服务时生成的内容(注意它缺少超时):

<bindings>
            <netTcpBinding>
                <binding name="NetTcpBinding_ITestService" transferMode="Streamed">
                    <security mode="None" />
                </binding>
            </netTcpBinding>
        </bindings>

有谁知道我做错了什么/错过了吗?

提前谢谢!


下面的每个请求是我的服务app.config和客户端的app.config:

服务:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" />
  </system.web>
  <system.serviceModel>
    <bindings>
      <netTcpBinding>
        <binding name="StreamingBinding" receiveTimeout="00:15:00" sendTimeout="00:15:00"
          transferMode="Streamed" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
          <security mode="None" />
        </binding>
      </netTcpBinding>
    </bindings>
    <services>
      <service name="TestService.Wcf.TestServiceWcf">
        <endpoint address="" binding="netTcpBinding" bindingConfiguration="StreamingBinding"
          contract="TestService.Wcf.ITestServiceWcf">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexTcpBinding" bindingConfiguration=""
          contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://localhost:8525/TestServiceService" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="">
          <serviceMetadata httpGetEnabled="false" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

客户端:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.serviceModel>
        <bindings>
            <netTcpBinding>
                <binding name="NetTcpBinding_ITestServiceWcf" transferMode="Streamed">
                    <security mode="None" />
                </binding>
            </netTcpBinding>
        </bindings>
        <client>
            <endpoint address="net.tcp://localhost:8525/TestServiceService"
                binding="netTcpBinding" bindingConfiguration="NetTcpBinding_ITestServiceWcf"
                contract="TestServiceService.ITestServiceWcf" name="NetTcpBinding_ITestServiceWcf">
                <identity>
                    <dns value="localhost" />
                </identity>
            </endpoint>
        </client>
    </system.serviceModel>
</configuration>

1 个答案:

答案 0 :(得分:0)

您是否将“StreamingBinding”与您的终端相关联?可能值得在“System.serviceModel”标签之间发布所有内容以查看缺少的内容。 从您的帖子看来,尽管您在两端使用netTcpBinding,但它们可能不是来自同一端点,即客户端可能只使用默认设置。

<services>
      <service name="ServiceName">
        <endpoint binding="netTcpBinding" bindingConfiguration="StreamingBinding"
          name="NetTcpEndPoint" contract="ServiceContractName" />
      </service>
    </services>