通过控制台应用程序实现WCF服务时,方法参数不匹配

时间:2012-12-28 15:51:34

标签: c# .net wcf wcf-binding

我正在尝试创建一个基本的WCF application并使用Console Application来调用该服务。我将service reference添加到WCF Service并在Console Application内将其称为

ServiceName.Service s = new ServiceName.Service();
string str = string.empty;
str = s.GetData(10);  // here i get an argument overload mismatch error

Service.cs WCF Service文件中,此方法定义为

public string GetData(int value)
{
    return string.Format("You entered: {0}", value);
}

为什么我在这种情况下得到参数重载不匹配错误?我是WCF的新手。我已将WCF服务添加为服务引用。

1 个答案:

答案 0 :(得分:0)

原来,该服务未正确托管。我重新构建了解决方案,并在重新托管WCF service client后才能正常工作。

参数对应于Service.cs

中定义的参数