This project has moved and is read-only. For the latest updates, please go here.


Aug 28, 2012 at 6:40 AM


Can you, please, put a complete sample of use MEF + MVC (dependency resolver) with the last version the MEF for web and Windows Store apps (1.0.15). On the web are very outdated.

Thank you very much.

Aug 28, 2012 at 7:08 AM


If you download the MEF source code from the CodePlex site (at, link on the right), you will find what you're looking for.

The projects of interest are /oob/sample/Microsoft.Composition.Samples.FabrikamBooks, which is an MVC4 app using Microsoft.Composition, and /oob/demo/Microsoft.Composition.Demos.Web.Mvc, which is the necessary integration code including an IDependencyResolver and some additional features.

Hope this helps; feel free to shoot some follow-up questions if you need more info!


Aug 28, 2012 at 9:33 AM

Hi Nick

Thanks for the reply. In the examples the parts are within FabrikamBooks project, what is the best way to use parts from other class libraries ?

Thank you very much.

Aug 28, 2012 at 11:50 AM
You can use the CompositionProvider.AddAssembly() and .AddAssemblies() static methods to user other assemblies. Classes in those assemblies under a "Parts" sub-namespace will be picked up just like those in the Parts folder under the web project.


On 28 August 2012 18:33, el_conde333 <> wrote:

From: el_conde333

Hi Nick

Thanks for the reply. In the examples the parts are within FabrikamBooks project, what is the best way to use parts from other class libraries ?

Thank you very much.

Read the full discussion online.

To add a post to this discussion, reply to this email (

To start a new discussion for this project, email

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at

Aug 29, 2012 at 3:51 AM

Specifically in the space of MVC 4 and MEF, an example of the following would be great. Alternatively, a better way of doing what I want is something I am open to.

We have several disjointed business areas, which the organisation wants to start to bring under a single 'look & feel' - e.g. portal. 

So what we are envisaging is something where we have multiple MVC 4 projects.

- a thin 'portal' framework MVC 4 project

- 1..n MVC 4 projects, that describe themselves via something like an IApplication interface (name, views, navigation, etc)


From what I've read, MEF would suit this quite well, but I'm looking for the 'stuff' that ties multiple MVC 4 applications together, using Controllers, Views, etc from the different projects.

Also, something that lets me dynamically build a menu from the 1..n applications implementation of IApplication.

Sep 20, 2012 at 2:46 PM

I am also interested in a 'portal framework' example.  In particular, I would like to be able to package MVC Areas into separate assemblies and inject them into a portal framework at run-time (think WebParts for MVC).  The examples that are out there using the older MEF are very complex and incomplete.  Do you think that this approach is possible or are the routing issues too complex?