System.InvalidOperationException: '绑定实例已经关联监听
System.InvalidOperationException: 'A binding instance has already been associated to listen
我刚刚为一个项目启动了 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. '
您需要修改端点地址的名称:
<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>
我刚刚为一个项目启动了 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. '
您需要修改端点地址的名称:
<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>