Search
1
vote
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.


Closed Sep 10 2011 at 1:14 PM by marlongrech

fixed By john Rayner


Comments

delightful wrote Feb 8 at 8: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?

marlongrech wrote Feb 6 at 3:56 PM
can you send the sample solution at marlongrech AT gmail

delightful wrote Feb 6 at 9: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)

delightful wrote Feb 3 at 3:43 PM
ok, here is the sample solution. thx.

marlongrech wrote Feb 3 at 1:03 PM
can you send me a repo project please

delightful wrote Feb 3 at 11: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.

mattilaj wrote Feb 23 2011 at 4:49 PM
Excellent, thank you!

marlongrech wrote Feb 22 2011 at 3:54 PM
Thanks for this !!!! you're the man

Updating...
© 2006-2012 Microsoft | Get Help | Privacy Statement | Terms of Use | Code of Conduct | Advertise With Us | Version 2012.2.15.18416