WPF research and prototyping

.NET, Technical stuff, WPF
See comments
Wow, one week without a post, means that something is cooking... and guess what, it's a new WPF prototype. I cannot publish anything yet, but the proof of concept works. It's been pretty much 24/7 for the last week (well, 18/7, I got to get some sleep from time to time ;-)
The idea behind this prototype is to allow loading User Controls dynamically in a WPF application. By placing the application on a website, and by having the application (served as XBAP, or installed as standalone) communicate with the website using web services, it's possible to dynamically notify WPF clients when a new UI element is available for the application, without having to restart the client or the server!
Actually, this would also be possible in a Windows Forms application, because this relies on two powerful features of the .NET framework:
- Any rich application can use web services to communicate easily with a web server.
- Using Assembly.LoadFrom, it's possible to download an assembly to a rich client, to dynamically load it into the AppDomain, and using reflection, to instantiate objects from this assembly.
Knowing this, it was not too tricky to prepare a design allowing DLLs to be compiled separately from the application, but yet fitting into it. To do that, each control wanting to appear in the client must implement an abstract class which we provide. This class is itself derived from System.Windows.Controls.UserControl. So when a DLL is uploaded to the web server (using FTP for example), in a given folder, the web service loads it, inspects it, and returns a list of suitable controls (actually, it returns the information needed to dynamically load them). What is needed is the Assembly URL, the control's type's full name, the assembly's full name, and if available, a display name (set using a custom attribute).
Once the information about the controls is available in the client application, the user may select one of these controls. If the control is already on the client, it is simply instantiated and loaded. If it is available on the web server, the assembly is loaded using Assembly.LoadFrom, and then the control is loaded. Since these controls derive from our abstract class, we can specify a minimal implementation which they must fulfill.
The nice thing is that I managed to get all this to work within the Internet zone permissions, meaning that we can use this with standalone WPF applications, but also with XBAPs. Using the Flexible Application Template, it is easy to switch from one to the other.
.NET is really exciting...
Previous entry | Next blog entry

Comments for WPF research and prototyping