In this article, I will tell you how to eliminate the collection already contains an address Exception in WCF.
In this article, I will tell you how to eliminate the "collection already contains an address Exception" in WCF.To understand this in depth you need to create a website that contains a WCF service.Step 1: Create a ASP.NET website named "WCF_Website".Step 2: Add a WCF service named "MyService" to it.Step 3: Add an "operation contract" into the interface of the WCF service.[OperationContractint Add(int a , int b);[OperationContract] int Add(int a , int b);
Step 4: Implement the entire interface in the "MyService" class and return the addition of both input values.public int Add(int a, int b){ return a + b;}
Step 5: Publish the website in a local folderThen publish it on the main server using FTP client or you directly publish it on the server.Problem: When you access your WCF service named "MyService.svc", it will generate an exception "collection already contains an address".Solution This is the current default settings in the web.config file.Add the following code to the <system.serviceModel> </system.serviceModel> section of the web.config file.
Note: Here my server domain name is "xyz".
Essential WCF Practical Implementation