【问题标题】:WPF app not updating timeout binding info for WCF serviceWPF 应用程序未更新 WCF 服务的超时绑定信息
【发布时间】:2014-02-03 23:02:09
【问题描述】:

我有一个解决方案,其中包含一个 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>

【问题讨论】:

    标签: c# wpf wcf


    【解决方案1】:

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

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

    【讨论】:

    • 我更新了上面的信息以显示完整的 app.config 文件。当我在同一个解决方案中引用服务时,会自动生成客户端的那个
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-20
    相关资源
    最近更新 更多