I recently encountered this issue when i was trying to help somebody else out with their issue. I debugged for the entire day without googling to try and understand the issue but to no effect. Ultimately it was google that helped me though :)
Error Description
This collection already contains an address with scheme http. There can be at most one address per scheme in this collection.
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.
Parameter name: item Then i thought this was related to IIS since IIS can have only one base address per web application. To check it out i did the following Open up the IIS Manager snap-in and right-click on the "Default Web Site" and select Properties. On the "Web Site" tab in the "Web Site Identification", click the "Advanced" button.
That should bring up the "Advanced Multiple Web Site Configuration" dialog box. Take a look at the top list box -- if there's more than one entry in there, that's likely the source of this problem. And that indeed was my problem!!!We had three base addresses like xxx.com,www.xxx.com,mydomain.mycompany.com
Fix We created our own servicehost and servicehostfactory to use the appropriate address for the service like this
class CustomHostFactory : ServiceHostFactory { protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses) { CustomHost customServiceHost = new CustomHost(serviceType, baseAddresses[2]); //We thought the last base address mydomain.mycompany.com would be more appropriate for our scenario. return customServiceHost; } }
class CustomHost : ServiceHost { public CustomHost(Type serviceType, params Uri[] baseAddresses) : base(serviceType, baseAddresses) { } protected override void ApplyConfiguration() { base.ApplyConfiguration(); } }
Now to associate our custome service host factory to our svc file
<%@ServiceHost language=c# Debug="true" Service="xxx.xxx.xxx.MyService" Factory="xxx.xxx.xxx.CustomHostFactory" %>
For more details, visit http://thoughtorientedarchitecture.blogspot.com/2009/11/collection-already-contains-address.html
|
No responses found. Be the first to respond and make money from revenue sharing program.
|