We would like to be able to communicate with a WPF application from the server.
Is it possible to have a WCF listener / service in a WPF application? And then call this service to open a screen in the WPF application?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It is fairly simple to create a WCF service listener/server anywhere you want.
One problem is that you have to have enough permissions to have your host be visible. You might have to elevate your application, and would definitely have to make sure the firewall (software/hardware) allows traffic to reach it.
This link seems to cover network setup for WCF MSDN samples, and applies both to IIS hosting, as well as your case, non-IIS hosted WCF:
http://msdn.microsoft.com/en-us/library/ms751527(v=vs.90).aspx
Also, you may run into threading complications, though you’ll run into these in any case where you are trying to update the UI from a background thread. If you have problems with this, look into the
Dispatcher:http://msdn.microsoft.com/en-us/magazine/cc163328.aspx
After that, it is up to you to create a client/server design that ensures that your service is created and listening at the right times, torn down at the right times (since
ServiceHostisIDisposable), and that it handles state correctly (in case operations get called at times you aren’t expecting – there are always bugs in any piece of software).WPF creates code that you can invoke more or less the same way you would in WinForms. You can still do a
new MainWindow().Show()call, for example. So simply add such code to your service implementation.