This project has moved and is read-only. For the latest updates, please go here.

DirectoryCatalog for Silverlight

Jan 26, 2010 at 9:36 AM

I've been looking for something like DirectoryCatalog for Silverlight.

For example I've got a IPlugin interface and some of its implementations in separate xaps. When I start SL application I want to look into some directory where I have this xap files and import all implementations of IPlugin interface.

I want to load next Plugins dynamically only for example by putting its xap files to this directory.

Have somebody idea how to do this ?

Jan 26, 2010 at 5:28 PM

By default Silverlight does not give you access to the file system so you cannot just load files from a directory, which is why DirectoryCatalog does not exist on Silverlight (it might be possible for out-of-browser trusted SL apps). However if you wish to have a collection of catalogs try using AggregateCatalog.

Jan 26, 2010 at 5:44 PM

Are you running an elevated / out of browser app? You need to in order to access the file system? A common pattern in SL is to download such plugins like you are describing from a remote server. This works in in-browser applications and does not require elevation.

You might want to check out out PackageCatalog that currently ships in the SL4 toolkit. It allows dynamically downloading XAPs from a remote server which contain parts. The XAPs are stored in the browser cached so that you do not need to download every time. You can download it at by following the SL4 beta link. You can also read about how it works here:

We are currently in the process of rolling this into SL4 proper in a new API called the DeploymentCatalog. We will be posting this in our next MEF SL codeplex drop which will make it also available for SL3.


Jan 27, 2010 at 11:42 AM

Thank you for reply.

I need to discover and dynamically download XAPs from a remote server. To use DownloadPackageAsync function I need to know path to the XAP file. I've already put xml file on the remote server with definitions for all XAPs. This allows me to use DownloadPackageAsync for each XAPs I've defined in xml file.
Have you better idea how to do this without this xml file?

Jan 27, 2010 at 11:47 AM

One way is to create a web service that looks in the client bin and finds all XAPs. Then have a web service (Json) that returns that list to the client. Once you have the list you can then dynamically use PackageCatalog to download.