WPF 内自托管 WCF

发布于 2024-10-09 00:24:07 字数 760 浏览 6 评论 0 原文

感谢 Kent Boogart 的回答,现在一切都正常了。非常感谢您的所有回答!


您好,

我需要在 WPF gui 中自行托管 WCF 服务。我正在使用服务主机。

但我仍然无法解决问题。

首先,我托管一个服务:

ServiceHost host;
Service.ISORClient service = new Service.SORClient();
//The next are in window constructor
host = new ServiceHost(service);
host.Open();

我想在按下按钮时刷新数据,所以:

dataGrid1.ItemsSource = service.GetPatients();

它可以工作,但只能一次。如果我尝试多次刷新它,它就不起作用。

这是我的 WCF 服务声明:

    [ServiceBehavior(InstanceContextMode=InstanceContextMode.Single)]
    public class SORClient : ISORClient
    ... and all the methods come here...

奇怪的是,当我从客户端应用程序连接时。我可以获得所有数据,并且一切都是正确的。我只是无法将数据输入 GUI(好吧,我只能获取一次)。

预先非常感谢您!

Thanks to Kent Boogart's answer everything is right now. Thank you very much for all answers!


Hello,

I need to self host a WCF service inside WPF gui. I'm using ServiceHost.

But I still can't solve the problem.

First I host a service:

ServiceHost host;
Service.ISORClient service = new Service.SORClient();
//The next are in window constructor
host = new ServiceHost(service);
host.Open();

And i want to refresh data when I press button, so:

dataGrid1.ItemsSource = service.GetPatients();

It works, but only once. If I try to refresh it more than one time, it just doesn't work.

Here's my WCF service declaration:

    [ServiceBehavior(InstanceContextMode=InstanceContextMode.Single)]
    public class SORClient : ISORClient
    ... and all the methods come here...

Weird thing is, that when I connect from a client app. I can get all the data, and everything is correct. I just can't get the data into GUI (well, I can get it only one time).

Thank you very much in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一杯敬自由 2024-10-16 00:24:08

抛开设计问题不谈,我怀疑你已经被平等所困扰了() 覆盖问题

尝试这样做来证明这一点:

dataGrid1.ItemsSource = null;
dataGrid1.ItemsSource = service.GetPatients();

Putting aside questions of design, I suspect you've been bitten by the Equals() override issue.

Try this to prove it:

dataGrid1.ItemsSource = null;
dataGrid1.ItemsSource = service.GetPatients();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文