我正在实现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