我正在實現WCF服務和客戶端應用程序。「App.CallbackHandler」不實現接口成員 - c#
有一個客戶端類:
private class CallbackHandler : ServiceReference1.IStockQuoteServiceCallback { public async Task SendQuoteAsync(string code, double value) { Console.WriteLine("{0}: {1:f2}", code, value); } }
以及服務接口類:
public interface IStockQuoteCallback { [OperationContract(IsOneWay = true)] Task SendQuote(string code, double value); }
我不知道爲什麼它說
'App.Program.CallbackHandler' 不實現接口成員 'App.ServiceReference1.IStockQuoteServiceCallback.SendQuote(字符串,雙)'
有關於上述代碼的服務參考:
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ServiceModel.ServiceContractAttribute(ConfigurationName="ServiceReference1.IStockQuoteService", CallbackContract=typeof(WSWCF_pretest_android.ServiceReference1.IStockQuoteServiceCallback))]
public interface IStockQuoteService {
[System.ServiceModel.OperationContractAttribute(IsOneWay=true, Action="http://tempuri.org/IStockQuoteService/StartSendingQuotes")]
void StartSendingQuotes();
[System.ServiceModel.OperationContractAttribute(IsOneWay=true, Action="http://tempuri.org/IStockQuoteService/StartSendingQuotes")]
System.Threading.Tasks.Task StartSendingQuotesAsync();
}
public interface IStockQuoteServiceCallback {
[System.ServiceModel.OperationContractAttribute(IsOneWay=true, Action="http://tempuri.org/IStockQuoteService/SendQuote")]
void SendQuote(string code, double value);
}
方法簽名應該是相同的。
有什麼建議嗎?
接口也不同。 IStockQuoteServiceCallback與IStockQuoteCallback – tnw 2014-09-29 15:55:00
但是,如果我將'ServiceReference1.IStockQuoteServiceCallback'重命名爲'ServiceReference1.IStockQuoteCallback',它不會找到類型... – Flash1232 2014-09-29 16:00:31
您確定*''在'ServiceReference1'中定義了''istockQuoteCallback''嗎? – tnw 2014-09-29 16:02:41