Jan 27, 2011 at 3:37 PM
Edited Jan 27, 2011 at 3:38 PM
I'm building a composite application that makes use of DeploymentCatalogs to load modules in the background. These elements use a common framework project that Exports various parts.
Currently these modules, lets call them ComponentsA and B, both distribute a Shared assembly in their respective .xap files. I'd like to include the shared assembly with the Main Silverlight application and remove it from the DeploymentCatalogs to save bandwidth.
Currently this is achieved in the following way:
public class MyBootstrapper : Bootstrapper<ShellViewModel>
private CompositionContainer _container;
protected override void Configure()
var aggCatalog = new AggregateCatalog(AssemblySource.Instance.Select(x => new AssemblyCatalog(x)).OfType<ComposablePartCatalog>());
// Load all core & shared assemblies into MEF/Caliburn
var assemblies = new List<Assembly>
typeof (Shared).Assembly // Can we populate this list with the DLLs distributed in the MainApp.xap ?
// Load modules in the background
var depCatalogs = new List<DeploymentCatalog>
// Select & Load only those Assemblies & Parts that are not already loaded
(s, ea) => dep.Parts
.Select(part => ReflectionModelServices.GetPartType(part).Value.Assembly)
.Where(assembly => !AssemblySource.Instance.Contains(assembly)).Distinct()
_container = CompositionHost.Initialize(aggCatalog);
I ensure that assemblies downloaded in DeploymentCatalogs are not loaded into MEF & CM more than once, I was having issues with it importing the same exports multiple times.So currently we've got the initial assemblies being loaded first.
Now there's quite a few assemblies that we want to distribute like this and it seems highly cumbersome adding a (SomeRandomClass).Assembly every time, is there a way to get all the assemblies distributed with the .xap loaded into MEF & Caliburn Micro?
The approach above goes through all those in DeploymentCatalogs but I can't seem to get at the main application's "catalog" as such. The approaches I've looked at seem to violate the Silverlight security model.