C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Errors and Solutions » General »

Collection already contains an address with scheme http


Posted Date: 03 Nov 2009    Resource Type: Errors and Solutions    Category: General
Author: HariMember Level: Gold    
Rating: 1 out of 5Points: 5



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



Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
WCF  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: WCF Service hosted in winforms and TimeOutexception
Previous Resource: What are .SQM files? How to remove them from C:\ drive?
Return to Discussion Resource Index
Post New Resource
Category: General


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use