views:

115

answers:

1

My scenario is a classic MEF scenario. There is a silverlight host app, and the app can download plugins on the fly to add functionality. Plug ins can be created by third parties.

Now the problem arises when different plugins and/or the host app reference different versions of the same assembly.

For example:

-plugin A references the version 1.0 of the silverlight toolkit dll and plugin B references the version 2.0 of the same dll.

OR

-host app references the version 1.0 of the reactive extensions dll and plugin C refernces the version 2.0 of the same dll.

That is a problem that is extremely likely to happen. Plugins and the host are all meant to be independent but with this problem in mind, I realise that a given plugin could work for a while, and then I update a reference of the host app, or add a new plugin, causing another plugin to break.

I've done some research on Silverlight Assembly loading and I believe that only one version of a given assembly can be loaded at a time. Therefore I don't know how to handle this.

Any ideas on that ?

A: 

You will need to exercise some control over what plugins the application can download and ensure that they work together if you want to ensure that this works.

If you have two plugins that reference different versions of the same assembly, you can get them both to work as long as there aren't any breaking changes in the assembly. You need to make sure that the more recent version of the assembly is loaded first, and then Silverlight will also use it for the plugin which references the older version of the assembly (note that this loader behavior is much different than how it works on desktop .NET).

If there are breaking changes in the different versions of the referenced assembly, then you won't be able to get both plugins to work.

Daniel Plaisted
Thanks for the details.That's pretty muched what I've realised while experimenting.Unfortunately it's not good enough for really dynamic scenarios when you cannot know in advance what plugins are going to be needed, and when.I guess I'm left to hope that the concept of AppDomain will be introduced in Silverlight 5..
Clems
@Clems How are your plugins being loaded? Don't they have to be downloaded from your server? So can't you exercise some control over them?
Daniel Plaisted