0

I am trying to host my WCF application on a web server. I am getting this error, but it is working fine in my local system

Error

This collection already contains an address with scheme http. There can be at most one address per scheme in this collection. If your service is being hosted in IIS you can fix the problem by setting 'system.serviceModel/serviceHostingEnvironment/multipleSiteBindingsEnabled' to true or specifying 'system.serviceModel/serviceHostingEnvironment/baseAddressPrefixFilters'.

Parameter name: item

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: This collection already contains an address with scheme http. There can be at most one address per scheme in this collection. If your service is being hosted in IIS you can fix the problem by setting 'system.serviceModel/serviceHostingEnvironment/multipleSiteBindingsEnabled' to true or specifying 'system.serviceModel/serviceHostingEnvironment/baseAddressPrefixFilters'. Parameter name: item

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[ArgumentException: This collection already contains an address with scheme http. There can be at most one address per scheme in this collection. If your service is being hosted in IIS you can fix the problem by setting 'system.serviceModel/serviceHostingEnvironment/multipleSiteBindingsEnabled' to true or specifying 'system.serviceModel/serviceHostingEnvironment/baseAddressPrefixFilters'. Parameter name: item]
System.ServiceModel.UriSchemeKeyedCollection.InsertItem(Int32 index, Uri item) +12089046
System.Collections.Generic.SynchronizedCollection`1.Add(T item) +78
System.ServiceModel.UriSchemeKeyedCollection..ctor(Uri[] addresses) +72 System.ServiceModel.ServiceHost..ctor(Type serviceType, Uri[] baseAddresses) +141
System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(Type serviceType, Uri[] baseAddresses) +30
System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses) +420
System.ServiceModel.HostingManager.CreateService(String normalizedVirtualPath) +1440
System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +44
System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +615

[ServiceActivationException: The service '/GUIService.svc' cannot be activated due to an exception during compilation. The exception message is: This collection already contains an address with scheme http. There can be at most one address per scheme in this collection. If your service is being hosted in IIS you can fix the problem by setting 'system.serviceModel/serviceHostingEnvironment/multipleSiteBindingsEnabled' to true or specifying 'system.serviceModel/serviceHostingEnvironment/baseAddressPrefixFilters'. Parameter name: item.] System.Runtime.AsyncResult.End(IAsyncResult result) +679246
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +190
System.ServiceModel.Activation.ServiceHttpModule.EndProcessRequest(IAsyncResult ar) +300622
System.Web.AsyncEventExecutionStep.OnAsyncEventCompletion(IAsyncResult ar) +8837348

Can any one help me to resolve this issue.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Santosh Sahu
  • 219
  • 1
  • 5
  • 13
  • 1
    Can you post the web.config for your WCF Service? Also are there other service hosted on the machine? Also Improve your accept reate 3 out of 10? – Amar Palsapure Feb 08 '12 at 06:28
  • Thanx for your responce. Yes It is working in my Local Mechine. And another thing is U are asking for Web config. I am afried to say that There is some sensitive data in the web config file. So Which portion you need. Only that portion I will send. Thanx – Santosh Sahu Feb 08 '12 at 06:55
  • @SantoshSahu: we need to see everything inside your `` tag - that's the WCF configuration – marc_s Feb 08 '12 at 07:41

2 Answers2

3

Original post from SO : WCF service startup error "This collection already contains an address with scheme http".

Please search before posting question.

You can check following solutions

  • Code solutions: Here
  • Configuration solutions:Here

I will suggest you go with the configuration solution, easy to change on the fly.

Check this how to alter your applications web config:

<system.serviceModel>
    <serviceHostingEnvironment>
        <baseAddressPrefixFilters>
            <add prefix="net.tcp://payroll.myorg.com:8000"/>
            <add prefix="http://shipping.myorg.com:9000"/>
        </baseAddressPrefixFilters>
    </serviceHostingEnvironment>
</system.serviceModel>

In the above example, net.tcp://payroll.myorg.com:8000 and http://shipping.myorg.com:9000 are the only base addresses, for their respective schemes, which will be allowed to be passed through. The baseAddressPrefixFilter does not support any wildcards .

The baseAddresses supplied by IIS may have addresses bound to other schemes not present in baseAddressPrefixFilter list. These addresses will not be filtered out.

Dns solution (untested): I think that if you created a new dns entry specific to your web application, added a new web site, and gave it a single host header matching the dns entry, you would mitigate this issue altogether, and would not have to write custom code or add prefixes to your web.config file.

Community
  • 1
  • 1
Amar Palsapure
  • 9,590
  • 1
  • 27
  • 46
0

Go through following links and you will get your problem solved. Same problem is resolved in these links.

WCF service startup error "This collection already contains an address with scheme http"

Server error in WCF

I suggest to check your web config file hierarchy to confirm that you are not using multiple endpoints with "no address".

Community
  • 1
  • 1
Arvind Dhasmana
  • 1,396
  • 2
  • 9
  • 8