Resolving a Problem When Adding A Reference to a WCF Service

Awhile ago, I was having issues adding a WCF service reference to a project I was working on. I was getting an error when trying to add the reference that said “Custom tool error: Failed to generate code for the service reference”. Looking at the Reference.cs file for the service, it was blank except for the comment block at the top.

The answer lied in one of the warning messages (I've changed some of the assembly and namespace names below to protect my company's privacy):

Custom tool warning: Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporter
Error: List of referenced types contains more than one type with data contract name 'Content' in namespace 'http://www.mycompany.com/backoffice/core/services'. Need to exclude all but one of the following types. Only matching types can be valid references:
"MyCompany.BackOffice.Core.Domain.Packaging.RadAssembly.Accessors.Content, MyCompany.BackOffice.Core.Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" (matching)
"MyCompany.BackOffice.Core.Domain.Packaging.CreativeCollection.Entities.Content, MyCompany.BackOffice.Core.Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" (not matching)
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://www.mycompany.com/backoffice/core/services']/wsdl:portType[@name='IRadAssemblyDatabridge'] C:\Projects\BackOffice\BackOfficeServices\branches\RadProgramming\Adaptation\Orchestration\RAD\src\Adaptation.Orchestration.RAD.Infrastructure\Service References\RadAssemblyDatabridge\Reference.svcmap 1 1 Adaptation.Orchestration.RAD.Infrastructure

In other words, two classes in different namespaces but with the same name. The fix was to change this:

[DataContract(Namespace = "http://www.mycompany.com/backoffice/core/services")]

To this:

[DataContract(Namespace = "http://www.mycompany.com/backoffice/core/services", Name = "RadAssemblyContentAccessor")]

Hopefully this will save someone some time if they run across the same issue.

Comments

Popular Posts

Resolving the "n timer(s) still in the queue" Error In Angular Unit Tests

How to Get Norton Security Suite Firewall to Allow Remote Desktop Connections in Windows

Silent Renew and the "login_required" Error When Using oidc-client

Fixing the "Please add a @Pipe/@Directive/@Component annotation" Error In An Angular App After Upgrading to webpack 4

How to Determine if a Column Exists in a DataReader