Self-hosting WCF inside WPF

Thanks to Kent Boogart to answer that everything is right now. Thanks so much for all the answers!


Hello,

I need to host the WCF service myself inside the WPF gui. I am using ServiceHost.

But I still can not solve the problem.

First I host the 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 update the data when I click the button, therefore:

 dataGrid1.ItemsSource = service.GetPatients(); 

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

Here is my WCF service declaration:

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

It is strange that when I connect from the client application. I can get all the data and everything is correct. I just can't get the data in the GUI (well, I can only get it once).

Thank you in advance!

+4
source share
1 answer

Leaving aside design issues, I suspect that you have been bitten by the problem of canceling Equals () .

Try this to prove it:

 dataGrid1.ItemsSource = null; dataGrid1.ItemsSource = service.GetPatients(); 
+2
source

Source: https://habr.com/ru/post/1333250/


All Articles