2
votes

I'm getting this error with a WCF service. This is the error report I get when I use the Microsoft Service Trace Viewer to view the error details:

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 'EchoAddress' in namespace 'http://schemas.datacontract.org/2004/07/WorldVision.NewZealand.CIMS.Common.Entities'. Need to exclude all but one of the following types. Only matching types can be valid references: "CIMS.CrmService.EchoAddress, App_WebReferences.k4hj-nad, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null" (matching) "CIMS.AddressService.EchoAddress, App_WebReferences.k4hj-nad, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null" (matching)

It reads like there are two separate classes called 'EchoAddress' that I've defined as WCF DataContracts using the [DataContract] attribute, that both exist in the WorldVision.NewZealand.CIMS.Common.Entities namespace. I've checked and this isn't the case. The error also says I need to exclude one of the following types:

CIMS.CrmService.EchoAddress CIMS.AddressService.EchoAddress

But I only declare the 'EchoAddress' class once, in the WorldVision.NewZealand.CIMS.Common.Entities namespace. It looks like these are references to the same type (EchoAddress), within both the 'CrmService' and 'AddressService', which are two separate WCF services that I'm referencing as 'service references' from my main project.

This is the type declaration for the EchoAddress class, which is declared in a separate project that then gets referenced by the project that contains the actual WCF services. My main project then references the service as a service reference:

[DataContract]
public class EchoAddress
{
    [DataMember]
    public string AddressType { get; set; }
    [DataMember]
    public Dictionary<string,string> AddressLines { get; set; }

    ...
}

I've tried the following:

Any ideas?

1
'Reuse types in reference assemblies' should definately be set to true. However, I agree with @user544550 on this - avoid using the built-in generate service reference if possible. - tom redfern

1 Answers

1
votes

Dueto various cryptic problems like this when our service complexity grew we moved away from the add service reference method completely. The reason was lack of control , gloat and errors. If you are primarily using the service from .net world then watch the following video

http://www.dnrtv.com/default.aspx?showNum=122

This will also give you a lot of internals info and help debug wcf issues. Once you make the move you will never come back!