合同属性无效

时间:2014-03-09 03:34:28

标签: wcf web-config

我已经达到了几个小时了。我收到此错误消息:

'contract'属性无效 - 值'AddressService.IAddressVerificationService'根据其数据类型'clientContractType'无效 - 枚举约束失败。

,配置文件如下所示:

<endpoint address="http://www.verifythisaddress.com/AddressVerification/AddressVerificationService.svc"
           binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IAddressVerificationService"
           contract="AddressService.IAddressVerificationService" name="BasicHttpBinding_IAddressVerificationService" />

我的服务开始如下:

namespace AddressVerificationWCF
{
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together.

[ServiceContract]
public interface IAddressVerificationService
{
    [OperationContract]
    Address VerifyThisAddress(string stuff);
}

}

我尝试了很多东西,例如更改名称,删除文件等等,但是我的头脑很难过。 感谢。

3 个答案:

答案 0 :(得分:4)

契约需要是接口的完全限定名称 - 通常是包含接口的命名空间,加上接口名称。查看您发布的代码,这应该是:

AddressVerificationWCF.IAddressVerificationService

所以你的配置看起来像是:

<endpoint address="http://www.verifythisaddress.com/AddressVerification/AddressVerificationService.svc"
          binding="basicHttpBinding"
          bindingConfiguration="BasicHttpBinding_IAddressVerificationService"
          contract="AddressVerificationWCF.IAddressVerificationService"
          name="BasicHttpBinding_IAddressVerificationService" />

答案 1 :(得分:0)

我遇到了类似的问题。我以管理员模式运行我的VS 2012并解决了它。

答案 2 :(得分:0)

The value is invalid according to its datatype 'clientcontracttype'

在上面文森特范登伯格建议下面解决了我的问题。感谢文森特...

<块引用>

当你在项目中缺少一个引用时会发生同样的错误 与 .config] 到包含 接口/服务契约...