1

Closed

Accept CompositionContainers created externally

description

Similar to the discussion at http://mefedmvvm.codeplex.com/discussions/215926, I needed to integrate Prism with MEFedMVVM but it wasn't acceptable to have two composition containers being created. This patch allows MEFedMVVM to accept a composition container created externally (in my case, by Prism). My application bootstrapper now looks like this:
 
public class Bootstrapper : MefBootstrapper, IComposer, IContainerProvider
{
    private CompositionContainer _compositionContainer;
 
    // Other stuff omitted for clarity
 
    protected override CompositionContainer CreateContainer()
    {
        // The Prism call to create a container
        var exportProvider = new MEFedMVVMExportProvider(MEFedMVVMCatalog.CreateCatalog(AggregateCatalog));
        _compositionContainer = new CompositionContainer(exportProvider);
        exportProvider.SourceProvider = _compositionContainer;
 
        return _compositionContainer;
    }
 
    CompositionContainer IContainerProvider.CreateContainer()
    {
        // The MEFedMVVM call to create a container
        return _compositionContainer;
    }
}
 
So you can see, I only have one CompositionContainer now.

file attachments

Closed Sep 10, 2011 at 12:14 PM by marlongrech
fixed By john Rayner

comments

marlongrech wrote Feb 22, 2011 at 2:54 PM

Thanks for this !!!! you're the man

mattilaj wrote Feb 23, 2011 at 3:49 PM

Excellent, thank you!

wrote Sep 10, 2011 at 12:14 PM

delightful wrote Feb 3, 2012 at 10:58 AM

can you please post the complete bootstrapper? what is with the IComposer implementation? I can't get it runnig, the designer shows my viewmodel successful but after loading the module over loadmodule on runtime, the exported view model was not found.

marlongrech wrote Feb 3, 2012 at 12:03 PM

can you send me a repo project please

wrote Feb 3, 2012 at 2:43 PM

delightful wrote Feb 3, 2012 at 2:43 PM

ok, here is the sample solution. thx.

delightful wrote Feb 6, 2012 at 8:51 AM

I got it. This
MEFedMVVM.ViewModelLocator.LocatorBootstrapper.ApplyComposer(this);
belongs into InitializeShell() and not into CreateShell(). (See a example of prism, mefedmvvm, cinchv2: http://www.codeproject.com/Articles/145175/Showcasing-Cinch-MVVM-framework-Prism-4-interopera?msg=3880049#xx3880049xx)

marlongrech wrote Feb 6, 2012 at 2:56 PM

can you send the sample solution at marlongrech AT gmail

wrote Feb 8, 2012 at 7:28 AM

delightful wrote Feb 8, 2012 at 7:28 AM

and your domain? .com doesn't work.
So again here. I was happy too early, at a first look, my fix worked but today i added a view model for the shell and i got a exception from mefedmvvm.
The joke is, if i use just one view model, the shell view model or the view model of the injected region view it works but not together. So in the attached example i commentet one view model out.
I hope you have an idea?

wrote Feb 14, 2013 at 6:47 PM

wrote May 16, 2013 at 8:39 AM