Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending WPF User Controls over WCF or similar

I am building an application in the MVVM style where the actual views (UserControls) are stored remotely and hopefully sent via a WCF service to my main application window. I am doing this in order to avoid having the user reinstall the application each time a new view is added. However, when I try to return a User Control from my WCF service I get an error stating:

System.Runtime.Serialization.InvalidDataContractException: Type 'System.Windows.Input.TouchDevice' cannot be serialized.

I am wondering if there is any way around this or if people have implemented something similar in other ways?

Thanks, Ochowie

like image 797
Ochowie Avatar asked Jan 27 '26 20:01

Ochowie


1 Answers

When you're loading from an assembly you're instantiating the compiled object from an assembly, which is a lot different than a deserialization operation, which is what is happening with a service call. The best you can do with serialization is transfer raw XAML that can be loaded with XamlReader, but this limits what you can do with a control since you can't use any code. If you're really set on hosting controls on your server the most flexible option would be to have your app download an assembly containing the new control and dynamically load the new assembly or use a separate launcher that can download new control assemblies before starting up the main application (make sure you take the time to understand the security implications and secure the assemblies and downloads).

like image 83
John Bowen Avatar answered Jan 30 '26 15:01

John Bowen