.net – WCF service startup error “This collection already contains an address with scheme http”


I built a web application containing a WCF service contract and a Silverlight control which makes calls to that WCF service. On my development and test servers it works great.

When I deploy to our live server and run the application I get an exception of type System.ServiceModel.ServiceActivationException which states that the service can not be activated due to an exception during compilation. The exception is:

This collection already contains an address with scheme http. There can be at most one address per scheme in this collection.

I read that this exception may be thrown if the web site has more than one host header, which is true on our live server. Apparently WCF services hosted in IIS can have only one base address. How can I get around this issue?

Best Solution

In .Net 4, you can use the multipleSiteBindingsEnabled option:

    <serviceHostingEnvironment multipleSiteBindingsEnabled="true">

Then, you won't have to specify each address.