WCF error: Need to exclude all but one of the foll

2019-08-03 04:41发布

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条回答
祖国的老花朵
2楼-- · 2019-08-03 05:27

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!

查看更多
登录 后发表回答