There's a few ways you can access parts via the container from within your Boostrapper class. The difficulty is that the boostrapper creates the container itself, so probably shouldn't have declarative attributes on itself. As well, the boostrapper
isn't meant to have a long lifetime either, so the recommendation is to do imports/exports using other classes.
Option A: Compose an instance directly
1. Create a class that uses [Import] (and/or [Export])
2. Override ConfigureContainer and instantiate your type, then call this.Container.ComposeExportedValue.
The MefBootstrapper does this for all the types that it or derived classes instantiate directly before the container is available.
Example: Composing the logger.
Option B: Satisfy imports to compse the Boostrapper.
I think of the MEF container kind of like the .NET garbage collector. The GC works from a root object and walks down a tree of everything that is referenced - anything not in the tree is a candidate for collection. The MEF container might know
about a bunch of exported types via its catalog, but doesn't really start resolving something until composes something that needs to resolve [Import] statements. The container then uses exports to resolve imports which might cause the need to resolve more
The MEF container doesn't know about the Boostrapper by default and no one asks to compose it, so imports are not resolved. Plus, you've already instantiated the Bootstrapper, so you'll have to put imports on fields/properties that allow recomposition.
1. Add a field or get/set property to your Boostrapper and place an [Import(AllowRecomposition=true)] attribute on it.
2. Override ConfigureContainer and call this.Container.ComposeParts(this).
2b. Alternatively, you could call this.Container.SatisfyImportsOnce(this) if you only want to satisfy the imports a single time.
Before using your type, you may want to wait until the imports are satisfied. The Shell.xaml.cs uses this technique.
3. Add IPartImportsSatisfiedNotification interface to the Boostrapper declaration.
4. Implement OnImportsSatisfied() and use your new type there.
I'm not sure if Option B is a good idea because then the container is holding a reference to something holding a reference to the container. This could cause a memory leak (at least until the app domain terminates).
If you have troubles, could you put some commented out code in your sample application of what you would like to have and I can try and work through how the container could resolve it for you.
Hope this helps,