感谢 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(好吧,我只能获得一次)。
非常感谢您!