views:

2985

answers:

5

I am trying to find out if anyone has any experience or ideas of using MEF (Managed Extensible Framework (Microsoft's new plugin framework) with ASP.NET MVC. I need to create a standard ASP.NET MVC, which I have. But I need to offer additional functionality i.e. Views and Controllers, etc, depending on if I add a plugin. It doesn't need to be dynamically compiled i.e. source code... but a DLL that i put into the system..

Is there any way to dynamically load a DLL when the app starts, and then MERGE a VIEWS and CONTROLLERS with the main system? I don't know if i am on the right track here.

Then, I suppose in the "STANDARD" views that come with the app, I can use an "IF THEN" to find out if a plugin is loaded and MERGE in a user control.

Well, I'm talking out loud here, but I think you understand what I am getting at.

Any ideas?

A: 

This is a wild guess. You could overwrite the default controller factory with one that uses MEF to discover IControllers. Since Views are discovered by convention, you shouldn't have to worry about them.

Jabe
+10  A: 

Hey, any luck on that? I was reading this and think that's what you're looking for.
I have exactly zero xp with MEF, but it looks promising. I hope I can scrape some hours of free time together at home to experiment with that. It would be ultra usefull to create some kind of modularized MVC "framework" that way.

As for the current project I'm working on, I have to following problem: Multiple sites with the same views, only other CSS files. Currently I have to duplicate the views resulting in a maintaince problem.
I'm hoping I can put these views in a central place using MEF.

borisCallens
Hammett has a good post here too: http://blogs.msdn.com/hammett/archive/2009/04/23/mef-and-asp-net-mvc-sample.aspx
Nathan Ridley
Yes, I read it a few days back. I must admit I didn't fully understand it, but I haven't found the time to re-read it neither. Deadlines kill progress ;)
borisCallens
Thanks for the comments, yep going to have a look at this.. its look really cool
mark smith
Here is another blog post about the subject: http://mikehadlow.blogspot.com/2010/10/experimental-aspnet-mvc-add-ins.html
robDean
+1  A: 

Check this :

http://www.fidelitydesign.net/?p=104

João Passos
Since the Poster left out any detail about the link here it is: Modular ASP.NET MVC using the Managed Extensibility Framework (MEF), Part One by Matthew Abbott of SO at http://stackoverflow.com/users/357693/matthew-abbott
Maslow
A: 

I have put together a pluggable framework using MVC and MEF with strongly-typed views over at : http://www.thegecko.org/index.php/2010/06/pluggable-mvc-2-0-using-mef-and-strongly-typed-views/

theGecko