[英]Self hosting WCF inside WPF
多虧肯特·布格(Kent Boogart)的回答,現在一切都變得如此。 非常感謝您提供所有答案!
你好,
我需要在WPF gui中自行托管WCF服務。 我正在使用ServiceHost。
但是我仍然無法解決問題。
首先,我托管服務:
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(嗯,我只能獲得一次)。
提前非常感謝您!
撇開設計問題,我懷疑您已經被Equals()覆蓋問題所困擾 。
嘗試一下以證明這一點:
dataGrid1.ItemsSource = null;
dataGrid1.ItemsSource = service.GetPatients();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.