Below is my WCF service configuration. I use 2 ServiceHost to host 2 types of services. They use the same base address, but use different relative addresses for their endpoints.
But I got this error, why?
The service cannot be started. System.InvalidOperationException: ChannelDispatcher in 'http: // earth: 1111 /' with contract '' IHttpGetHelpPageAndMetadataContract '' cannot open its IChannelListener. ---> System.InvalidOperationException: registration already exists for URI 'http: // earth: 1111 / '.
<?xml version="1.0" encoding="utf-8" ?> <configuration> <system.serviceModel> <behaviors> <serviceBehaviors> <behavior name="serviceBehavior"> <serviceMetadata httpGetEnabled="true" /> </behavior> </serviceBehaviors> </behaviors> <services> <service behaviorConfiguration="serviceBehavior" name="Distributed.Troubleshooting.System.IIS.IISServiceType"> <endpoint address="iis" binding="basicHttpBinding" name="iis" contract="Distributed.Troubleshooting.System.IIS.IISServiceContract" /> <endpoint address="iismex" binding="mexHttpBinding" bindingConfiguration="" name="iismex" contract="IMetadataExchange" /> <host> <baseAddresses> <add baseAddress="http://Earth:1111/" /> </baseAddresses> </host> </service> <service behaviorConfiguration="serviceBehavior" name="Distributed.Troubleshooting.System.SQL.SQLServiceType"> <endpoint address="sql" binding="basicHttpBinding" name="sql" contract="Distributed.Troubleshooting.System.SQL.SQLServiceContract" /> <endpoint address="sqlmex" binding="mexHttpBinding" bindingConfiguration="" name="sqlmex" contract="IMetadataExchange" /> <host> <baseAddresses> <add baseAddress="http://Earth:1111/" /> </baseAddresses> </host> </service> </services> </system.serviceModel> </configuration>
Some even more ridiculous conclusions:
I changed my configuration to the following:
<?xml version="1.0" encoding="utf-8" ?> <configuration> <system.serviceModel> <behaviors> <serviceBehaviors> <behavior name="serviceBehavior"> <serviceMetadata httpGetEnabled="true" /> </behavior> </serviceBehaviors> </behaviors> <services> <service behaviorConfiguration="serviceBehavior" name="Distributed.Troubleshooting.System.IIS.IISServiceType"> <endpoint address="http://Earth:1111/iis" binding="basicHttpBinding" name="iis" contract="Distributed.Troubleshooting.System.IIS.IISServiceContract" /> <endpoint address="http://Earth:1111/iismex" binding="mexHttpBinding" bindingConfiguration="" name="iismex" contract="IMetadataExchange" /> <host> <baseAddresses> <add baseAddress="http://Earth:1111/iis" /> </baseAddresses> </host> </service> <service behaviorConfiguration="serviceBehavior" name="Distributed.Troubleshooting.System.SQL.SQLServiceType"> <endpoint address="http://Earth:1111/sql" binding="basicHttpBinding" name="sql" contract="Distributed.Troubleshooting.System.SQL.SQLServiceContract" /> <endpoint address="http://Earth:1111/sqlmex" binding="mexHttpBinding" bindingConfiguration="" name="sqlmex" contract="IMetadataExchange" /> <host> <baseAddresses> <add baseAddress="http://Earth:1111/sql" /> </baseAddresses> </host> </service> </services> </system.serviceModel> </configuration>
Then I found that I could use the "Add Service Link" in Visual Studio with the following addresses:
source share