I have a Silverlight 4 application that I want to double as a Kiosk application. It has to be full screen, touch-enabled, and most importantly have full trust. I was thinking of doing this using a WPF application to host the Silverlight XAP. I am aware of the WPF/XNA SilverlightViewport, but it seems that this solution doesn’t provide communication between WPF and Silverlight.
This would really save me a whole lot of time. I would not have to maintain two distinct applications that do the exact same thing, and I wouldn’t have to deploy to hundreds of kiosks every-time I make a change.
I know it’s an old question, but I do have a solution.
I do this exact scenario. I host a Silverlight app in a WPF host. I use self hosted WCF to deliver duplex net tcp services. To do this, you have to also have a HTTP hosted clientaccesspolicy.xml, which I also self host from the same service.
I hope I can explain enough to get the ball rolling. I’ll include some samples where I can, however due to the project I can’t share everything.
Firstly, some considerations:
1) net tcp is not secure between Silverlight and WPF as Silverlight (as of version 4 – just testing version 5) cannot do the secure connections, so you have to roll your own encryption if you are to use this.
2) There are two methods to doing duplex WCF, one is with HTTP. The HTTP method ‘polls’ the service to see if any commands are coming from the host for the client. This inherently makes it much slower than net tcp. The other is with net tcp (as stated earlier). Only http method supports encryption out of the box.
3) When you host the Silverlight app in the WPF host, when you start to debug, you will not be able to debug your Silverlight app, as the debugger will not connect to the (as it sees it) external Silverlight application, only the WPF. To get around this, you have to ‘activate’ the attachment to the Silverlight application when you start the WPF host.
Now for the code:
Remote Service Interface:
Your policy listener interface:
The actual service implementation:
The above should be in separate classes in one dll project, and then referenced by your WPF host.
And to host it in a console app (you need to convert this to WPF):
Which should give you something to work on. The startremoteservice bool can be used to just make it a policy file listener, which then will allow you to connect to a remote service without that remote service having to host a policy file.
Remember, that Silverlight can only connect to HTTP/HTTPS ports, and TCP ports within the range of 4502-4534. The included clientaccesspolicy.xml is quite unrestricted.
I hope this is of use to someone 🙂 .
Feel free to ask me questions if you want, I’ll keep a look out.
A couple of points of note: You can serve your hosted xap from this solution, and therefore do not require IIS. You can also run your Silverlight xap out of browser and still use these services.
The debugging answer is here: Debugging Silverlight hosted in WPF