我在使用 Windows 8 编程时遇到很多问题。
一个问题是,我无法安装 IIS,因为 Windows 8 给我带来了问题,因为我使用 7 双重启动它。任何操作系统更新都会失败,包括配置更改,例如添加 IIS。
但无论如何,为了解决这个问题,我决定在带有 TCP 端点的 Windows 服务中托管 WCF 服务,并在我的商店应用程序中使用该服务。对于插入,它可以工作,不是问题。
但是当我去检索一些数据(一个非常小的数据集 - 3条记录)时,显示以下错误:服务器没有提供有意义的回复;这可能是由合同不匹配、会话过早关闭或内部服务器错误引起的。
我已经用谷歌搜索过这个错误,它似乎是一个常见的错误——这意味着它可能是任何东西。但我完全是 WCF 的菜鸟。
我在 ViewModel 中的代码很简单:
private async void PopulatePeople()
{
var people = await licenceBucketService.GetAllPersonsAsync();
FirstName = people.First().FirstName;
LastName = people.First().LastName;
}
GetAllPersons 方法是:
public ObservableCollection<Person> GetAllPersons()
{
ObservableCollection<Person> people = null;
using (var context = new LicenceBucketContext())
{
people = new ObservableCollection<Person>(context.People);
}
return people;
}
Reference.cs 文件中的异步版本如下所示:
public System.Threading.Tasks.Task<System.Collections.ObjectModel.ObservableCollection<Win8UI.LicenceBucketService.Person>> GetAllPersonsAsync() {
return base.Channel.GetAllPersonsAsync();
}
有任何 WCF 大师看到我的问题吗?