Geeks With Blogs


What I do:

Identity Mine

MVVM Light


What I am:

Microsoft Most Valuable Professional, Client Application Development

Microsoft Certified Technology Specialist, Windows Presentation Foundation

WPF disciples


View my profile on LinkedIn

Creative Commons License
Diary of a Code Trotter by Laurent Bugnion is licensed under a Creative Commons Attribution 3.0 Unported License

All source code on this blog is licensed under the MIT license.

Copyright (c) 2006 - 2011 GalaSoft Laurent Bugnion

Laurent Bugnion (GalaSoft) Diary of a Code Trotter
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...
Posted on Thursday, October 19, 2006 10:46 PM Technical stuff , .NET , WPF | Back to top

Comments on this post: WPF research and prototyping

Comments are closed.
Comments have been closed on this topic.
Copyright © Laurent Bugnion | Powered by: