I can get no satisfaction :(

Topics: Prism v4 - Silverlight 4
Dec 10, 2010 at 2:13 PM
Edited Dec 10, 2010 at 2:13 PM

Playing with the modularity sample.

I modified the ModuleControl to have an import of IModuleCatalog (exactly as in the Shell).

But it does not get satisfied, why does it get satisfied in the shell and not in the ModuleControl. Tried several things at the end I had something like this,

and if I uncomment the SatisfyImports I get an error that it cannot find the ImoduleCatalog.

    public partial class ModuleControl : ContentControlIPartImportsSatisfiedNotification
        /// <summary>
        /// Initializes a new instance of the <see cref="ModuleControl"/> class.
        /// </summary>
        public ModuleControl()
            this.Loaded += new RoutedEventHandler(ModuleControl_Loaded);

        void ModuleControl_Loaded(object sender, RoutedEventArgs e)

        [Import(AllowRecomposition = false)]
        public IModuleCatalog moduleCatalog;
Dec 10, 2010 at 6:45 PM


The issue you are experiencing might be because of the CompositionInitializer class. You could try accessing your ModuleCatalog through the Service Locator, as shown in the following snippet:

public ModuleControl()

     this._moduleCatalog = ServiceLocator.Current.GetInstance<IModuleCatalog>();

private IModuleCatalog _moduleCatalog;

I hope you find this information useful.


Miguel Bronzovic

Dec 11, 2010 at 11:21 AM

Yes, thanks,  that works, but still does not really answer my question. Why the difference.

Actually same thing , when in the importssatisfied in the shell , I add a module to modulecatalog... and it automatically gets downloaded

But if I do exactly the same in the ModuleControl 'loaded' event, nothing happens.

There is too much mystic stuff here....



Dec 13, 2010 at 6:45 PM


The behavior you're describing could be caused by a timing issue, since the loading sequence started by the MefBootstrapper.Run method calls the CreateShell and InitializeShell methods before the InitializeModules method. There should be no difference between the import you get when resolving it from the shell or the ModuleControl, since the catalog from which you're retrieving the imports is the same.

I hope you find this helpful.

Guido Leandro Maliandi