【问题标题】:System.InvalidOperationException: 'A binding instance has already been associated to listenSystem.InvalidOperationException: '绑定实例已经被关联到监听
【发布时间】:2021-07-09 05:03:11
【问题描述】:

我刚刚为一个项目启动了 WCF,它显示了以下异常,但是我发现了一些与此问题相关的问题,但我无法在我的代码中找到,我将代码放在这里,请查看并提出建议我的代码的最佳解决方案。

    <system.serviceModel>
    <services>
      <service name="CompanyService.CompanyService" behaviorConfiguration="mexBehaviour">
        <endpoint address="CompanyService" binding="basicHttpBinding" contract="CompanyService.ICompanyPublicService"></endpoint>
        <endpoint address="CompanyService" binding="netHttpBinding" contract="CompanyService.ICompanyConfidentialService"></endpoint>
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8080/"/>
            <add baseAddress="net.tcp://localhost:8091/"/>
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="mexBehaviour">
          <serviceMetadata httpGetEnabled="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

下面是错误异常:

'A binding instance has already been associated to listen URI 'http://localhost:8080/CompanyService'. If two endpoints want to share the same ListenUri, they must also share the same binding object instance. The two conflicting endpoints were either specified in AddServiceEndpoint() calls, in a config file, or a combination of AddServiceEndpoint() and config. '

【问题讨论】:

  • 检查这个question。您似乎遇到了同样的问题。

标签: asp.net wcf


【解决方案1】:

需要修改端点地址的名称:

    <services>
      <service name="CompanyService.CompanyService" behaviorConfiguration="mexBehaviour">
        <endpoint address="CompanyService01" binding="basicHttpBinding" contract="CompanyService.ICompanyPublicService"></endpoint>
        <endpoint address="CompanyService02" binding="netHttpBinding" contract="CompanyService.ICompanyConfidentialService"></endpoint>
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8080/"/>
            <add baseAddress="net.tcp://localhost:8091/"/>
          </baseAddresses>
        </host>
      </service>
    </services>

【讨论】:

    猜你喜欢
    • 2012-11-18
    • 1970-01-01
    • 2012-07-15
    • 1970-01-01
    • 2018-09-01
    • 2019-12-02
    • 2022-01-13
    • 2019-07-08
    • 1970-01-01
    相关资源
    最近更新 更多