Recomposition issue with a Modular Silverlight application
===

I'm working with a Silverlight 4 application and we use Prism/MEF to build modules.

Each module is created as a Silverlight application.  We then use a ModulesCatalog.xaml file to control how the modules are loaded.

We had 6 modules and everything was working perfect.

This week we're adding a 7th module and we just have the new Silverlight application created.  We setup the module class as follows.

     [ModuleExport(typeof(InsightModule))]
    public class InsightModule : IModule
    {

    }

Then we added an entry to our ModulesCatalog file.

Now when we run the application we start getting all types of recomposition errors.  The stack shows this.

   at System.ComponentModel.Composition.CompositionResult.ThrowOnErrors(AtomicComposition atomicComposition)
   at System.ComponentModel.Composition.Hosting.ExportProvider.OnExportsChanging(ExportsChangeEventArgs e)
   at System.ComponentModel.Composition.Hosting.CatalogExportProvider.OnCatalogChanging(Object sender, ComposablePartCatalogChangeEventArgs e)
   at System.ComponentModel.Composition.Hosting.ComposablePartCatalogCollection.OnChanging(Object sender, ComposablePartCatalogChangeEventArgs e)
   at System.ComponentModel.Composition.Hosting.AggregateCatalog.OnChanging(ComposablePartCatalogChangeEventArgs e)
   at System.ComponentModel.Composition.Hosting.ComposablePartCatalogCollection.RaiseChangingEvent(Lazy`1 addedDefinitions, Lazy`1 removedDefinitions, AtomicComposition atomicComposition)
   at System.ComponentModel.Composition.Hosting.ComposablePartCatalogCollection.Add(ComposablePartCatalog item)
   at Microsoft.Practices.Prism.MefExtensions.Modularity.MefModuleInitializer.CreateModule(ModuleInfo moduleInfo)
   at Microsoft.Practices.Prism.Modularity.ModuleInitializer.Initialize(ModuleInfo moduleInfo)

Then you get the standard output.

    - The exception message was: The composition remains unchanged. The changes were rejected because of the following error(s): The composition produced multiple composition errors, with 57 root causes. The root causes are provided below. Review the CompositionException.Errors property for more detailed information.

1) Change in exports prevented by non-recomposable import 'EyeCue.Common.AboutEyeCueView.ViewModel (ContractName="EyeCue.Common.AboutEyeCueVM")' on part 'EyeCue.Common.AboutEyeCueView'.

WHat's puzzling is why none of the other 6 modules caused this problem but now all of a sudden, this new module without anything going on in it is causing a recomposition of the catalogue.  It makes no sense.

Plus I have ctor's that import in some cases and that's they what I had to do to get things to work, so this is not as simple as going to setting the Allow Recomposition attribut.

I've downloaded the VisualMFX but this line of code throws an Object Not initialized exception.

this.compositionInfo = new CompositionInfo(_aggregateCatalog,  _container);

Both -aggregateCatalog & _container are not null when this happens.

In summary, why would a 7th module all of a sudden start causing recomposition?  Especially when the module isn't even defining any exports or imports at this time?  That leads to how do we stop it to address this problem?





