我正在WCF中創建基本的Add 2 numbers
服務。我加入裏面IService.cs
無法引用WCF中的操作合同方法
[ServiceContract]
public interface ICalc{
[OperationContract]
int Add(int a, int b);
}
下列現在,Service.cs
裏面我已經加入
public class Service: IService, ICalc {
public int Add(int a, int b){
return a+b;
}
}
現在我建立這個服務並添加service reference to it
控制檯應用程序
Program.cs
這裏面被稱爲
ICalService.Service c = new ICalService.Service();
int result = c.Add(10,20); //Now on this line I cannot seem to get the Add(int a, int b) method
我早先宣佈的
。
ICalService
是我在服務被引用時給予的名稱。
爲什麼Add(int a, int b)
方法不顯示?
IService是我在創建WCF服務時生成的預定義接口。我只是簡單地加了ICalc。我嘗試了多次重建它,但即使Add(int a,int b)被引用時,它也表示了agrument重載不匹配。我想我肯定錯過了一步,因爲這也是我第一次使用WCF – user544079