感谢 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!
发布评论
评论(1)
抛开设计问题不谈,我怀疑你已经被平等所困扰了() 覆盖问题。
尝试这样做来证明这一点:
Putting aside questions of design, I suspect you've been bitten by the Equals() override issue.
Try this to prove it: