Loading Modules via ClickOnce

Topics: Prism v2 - WPF 3.5
Mar 5, 2009 at 11:42 PM
I'm contemplating loading modules from an application deployed via click once. While the Silverlight implementation supports loading from an XAP file via a URL similar functionality for the desktop is absent.  Is this a bad idea or just a feature which has not been needed yet?  I don't have experience with MEF yet, perhaps it provides the required functionality?

Shane Holder

Mar 6, 2009 at 4:30 PM
We didn't build a remote downloading component for WPF because you can achieve that with ClickOnce.

This doc describes how to do that:
http://msdn.microsoft.com/en-us/library/dd458921.aspx

If you don't want to use ClickOnce, you can also easily build your own module downloading component and plug it into prism.

I don't believe MEF has any remote module loading capabilities, but i'm not sure.

Hope this helps,
Erwin
Mar 6, 2009 at 6:50 PM

Hi Shane,

 

That Silverlight feature tries to solve bandwidth problems, avoiding downloading modules that your application will not use in that moment. The main requirement for this environment is that all the modules required by your application should be hosted in the Web Server, so your Silverlight application will be able to download them.

If I understaned correctly, you are trying to know when you are deploying your WPF application (using ClickOnce) the modules that it will be use, to only download/install these. I think that it is not usually possible to define in this step. A possible workaround could be creating different ClickOnce installers based on the modules that the application will use (for example, if you are loading different modules based on Authentication (Roles), you can create an installer for Administrators users and other for Common users). Or perhaps, you can implement a Shared folder on your network and host all the required modules by your application on it. Then, you can configure your module catalog to use a configuration file to define the modules that your application will be use specifying the full path for each module.  

In this way, you can simulate a similar environment like the Silverlight remote module loading feature: All the required modules are hosted in a “Server” and your application will “download” only the required modules from it. You should take into account that this solution downloads every time the  different modules from the Shared Folder. If you are thinking on implement something like this, probably, you find useful the following article in the documentation:

·         Populating the Module Catalog from a Configuration File

 

If you are interested in modifying or extending the Composite Application Library (CAL), the best way to do that is creating a custom Module Loader class to implement something similar to the XapModuleTypeLoader class (defined inside the Modularity folder of the Composite.Silverlight project).

First of all, you should package your modules’ Dlls in a zip file or similar (a possible way to implement this is using any command-line zip tool and executing it in the post build event of your modules).

Then you should implement the custom Module Loader class. It should implement the IModuleTypeLoader interface and should be able to:

1.       Download the Zip file from an specific location.

2.       Extract the content (you can find a lot of C# class to manage zip files surfing the web).

3.       Load the packaged assemblies (your modules).

 

Also perhaps, you may want to read how the Prism-v2’s team recommends deploying WPF applications using ClickOnce:

·         Deploying WPF Applications with ClickOnce

 

Please, let me know if this helps.

 

Ezequiel Sculli

http://blogs.southworks.net/esculli/

Mar 7, 2009 at 5:26 AM
Edited Mar 7, 2009 at 5:31 AM
Erwin, I don't believe that this scenario is easily facilititated via straight up click once.  What I'm thinking is a plugin scenario where plugin's are dropped into a modules directory on the server and loaded.  It is my understanding that for click once all of the files deployed via click once need to be in the original application's manifest.  Which would mean for each plugin deployed the manifest would need to be modified, not really what I was hoping to do.

Shane
Mar 7, 2009 at 5:35 AM
Ezequiel,

I think you've understood my scenario correctly except that it's not so much a download only the modules required as an extensability feature.  It doesn't look too difficult to do and since I did not see an implementation already I was concerned that it was a bad idea.

Shane Holder

Apr 9, 2009 at 2:05 AM
Hi Shane,

I believe that I'm trying to achieve the same WPF module loading capability.  Have you been able to make progress on this function?  Did you end up implementing IModuleTypeLoading?

Cheers,
Jeff
Apr 30, 2009 at 9:18 PM
Hi, this looks like the right thread for this.
I'm currently developing a WPF application, not with prism itself, but with framework I create which resumable some of Prism capabilities, especially dynamic module loading.
I'm deploying my application using ClickOne and I too have the trouble that Visual Studio regular Publish command does not pick up the dynamic modules project since my main application does not have a reference to them.
So, I end up publish the application to my computer, use ManifestManagerUtility (which I tweak a little) to add the dynamic modules and repackage everything.

My question is have can I stream-line the process, maybe add a MSBuild task to add the dynamic modules, since I can explain the build system which project output needs to be added, maybe even change the ClickOnce publish task to add the dynamic modules when the regular publish take place and solve the problem in one shot.

Thank you,
Ido.