【问题标题】:Silverlight wcf service - change return value of methodSilverlight wcf 服务 - 更改方法的返回值
【发布时间】:2014-04-18 00:03:52
【问题描述】:

在我的服务中,我有一个返回布尔值的方法,但后来我将其更改为 IList,我更新了 服务通过右键单击服务参考并进行更新。然而,更新并没有更新方法返回值。对于此代码,我收到一条错误消息,显示“无法将类型 bool 隐式转换为 System.Collection.Generic.IList<..>”

patientService.SavePatient(personID, firstName, lastName, causeOfVisit,(s, e) => PatientData = e.Result);

服务中的方法:

    [OperationContract]
    public IList<Patient> SavePatient(string personId, string firstName, string lastName, DateTime TimeOfArrival, string causeOfVisit)
    {
        patientRepository.SavePatient(personId, firstName, lastName, TimeOfArrival, causeOfVisit);
        return patientRepository.Patients;
    }

我该如何解决这个问题?

【问题讨论】:

  • 您使用的是Silverlight-enabled WCF service 还是只使用WCF 服务?
  • 更新服务引用前是否重启了服务?
  • 启用 Silverlight 的 WCF 服务!重启?
  • 删除引用并再次尝试添加
  • 我这样做了,没用。

标签: wcf silverlight


【解决方案1】:

当您更改将布尔值返回到 IList 时,您是否在进行更新服务参考之前在顶部菜单的 Build 中构建了解决方案?因为在我看来,自从您忘记该步骤以来,它仍然返回 bool,它需要在服务器端(Projectname.web)中更新这两个步骤,您可以在其中通过构建解决方案和客户端定义 WCF,因为您做得很好更新服务参考。


WCFservice.TopicInfoAsync(query_topics, (int)numberOfTopics);
WCFservice.TopicInfoCompleted += (Stopicinfo, EAtopicinfo) =>
{
   TopicList = EAtopicinfo.Result;
}

【讨论】:

  • 在您的 wcfservice PatientService 中,它不是像我的评论中添加的代码那样附加到异步,然后是另一个事件,当它完成并返回时,您似乎在那一行代码中做到了这一点但你不应该调用 SavePatientAsync 吗??
  • 我不完全理解您的评论,但 patientService 是一个具有服务变量的类。方法 savePatient 调用 client.SavePatientCompleted += callBack; client.SavePatientAsync(personId, firstName, lastName, DateTime.Now, causeOfVisit);客户就是服务。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-12-22
  • 1970-01-01
  • 1970-01-01
  • 2010-09-07
相关资源
最近更新 更多