Dynamic XAP Discovery with Silverlight MEF

added by crpietschmann
9/30/2010 10:03:13 PM

0 Kicks, 115 Views

What's missing, it seems, is a mechanism to dynamically discover the XAPs that are available on the server. If I'm using MEF to support a plug-in architecture, for example, I might want to drop a XAP containing a new plug-in into a folder on the server and have the plug-in automatically show up in my browser the next time the application runs. MEF won't do that on its own, but it will if you lend it a helping hand. After discussing various ways to do dynamic discovery in MEF with Jeremy Likness, I wrote a sample to demonstrate a technique based on passing InitParams to the Silverlight control. The technique is pretty simple. You begin by modifying the ASPX file that hosts your Silverlight application. First, you add an empty InitParams <params> element to the <object> element that instantiates the Silverlight control, and you include an ID and a runat="server" attribute so you can manipulate the element from server-side code: