MEF + MVC

Aug 28, 2012 at 5:40 AM

Hi

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 6:08 AM

Hi,

If you download the MEF source code from the CodePlex site (at http://mef.codeplex.com/SourceControl/list/changesets, 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!

Cheers,
Nick

Aug 28, 2012 at 8: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 10: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.

Cheers,
Nick

On 28 August 2012 18:33, el_conde333 <notifications@codeplex.com> 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 (MEF@discussions.codeplex.com)

To start a new discussion for this project, email MEF@discussions.codeplex.com

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

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


Aug 29, 2012 at 2: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 1: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?