WCF错误:需要排除以下类型之一以外的所有类型.仅匹配类型可以是有效引用 [英] WCF error: Need to exclude all but one of the following types. Only matching types can be valid references

查看:45
本文介绍了WCF错误:需要排除以下类型之一以外的所有类型.仅匹配类型可以是有效引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在WCF服务中遇到此错误.这是我使用Microsoft Service Trace Viewer查看错误详细信息时得到的错误报告:

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:

运行WSDL导入扩展时引发了异常:System.ServiceModel.Description.DataContractSerializerMessageContractImporter错误:引用类型的列表在名称空间' http://schemas.datacontract.org/2004/07/WorldVision.NewZealand.CIMS.Common.Entities ".需要排除以下类型之一以外的所有类型.只有匹配类型可以是有效的引用:"CIMS.CrmService.EchoAddress,App_WebReferences.k4hj-nad,版本= 0.0.0.0,区域性=中性,PublicKeyToken =空"(匹配)"CIMS.AddressService.EchoAddress,App_WebReferences.k4hj-nad,Version = 0.0.0.0,Culture = neutral,PublicKeyToken = null"(匹配)

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)

它看起来就像有两个名为"EchoAddress"的单独类,我已经使用[DataContract]属性定义为WCF DataContracts,它们都存在于WorldVision.NewZealand.CIMS.Common.Entities命名空间中.我已经检查过了,事实并非如此.该错误还表示我需要排除以下类型之一:

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.EchoAddressCIMS.AddressService.EchoAddress

CIMS.CrmService.EchoAddress CIMS.AddressService.EchoAddress

但是我只在WorldVision.NewZealand.CIMS.Common.Entities命名空间中声明了'EchoAddress'类一次.看起来这些是在"CrmService"和"AddressService"中对相同类型(EchoAddress)的引用,它们是我从主项目中引用为服务引用"的两个单独的WCF服务.

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.

这是EchoAddress类的类型声明,它在一个单独的项目中声明,然后由包含实际WCF服务的项目引用.然后,我的主项目将服务引用为服务引用:

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; }

    ...
}

我尝试了以下操作:

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆