Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: MVC MEF
Hi all, I've been googling a lot about this but it seems there is no up-to-date solution (e.g. see here[^]). Basically I'd like to build an MVC 4 web app acting as a host for plugins. Each plugin should expose controllers (exported via MEF into their DLL) plus content files (views and the like), that I'll just copy in the web host during plugin installation. Plugins should be loaded dynamically via MEF, and it should be possible to add them without having to restart the web app.
 
I thus need:
 
* a MEF-aware IoC tool for non-trivial injections (for basic duties I could just rely on MEF itself). I chose Autofac, which has a MEF-adapter easily installable from NuGet and up to date for MVC4.
 
* a MEF-based controller factory, to let my web app find the controllers exported by plugins. See this post[^] for a good sample, also integrated into a NuGet package.
 
* a shadow plugins folder to load my plugins from (using a MEF DirectoryCatalog). On startup the application copies all the plugins DLLs from the Plugins folder to a shadow subfolder and let the MEF catalog point to them, so that I can later overwrite the plugins without being blocked by file locks.
 
After putting all these pieces together, I found that my MEF controller factory always gets a null controllerType from the MVC framework, so it fails even before it can execute. I suspect some kind of namespace-related issue here, but I don't know MVC internals enough. You can download a full dummy repro solution from here[^]. I'm stuck with this, could anyone help? It should not be so hard integrating MVC+MEF...
Posted 5-Jan-13 8:37am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 273
1 Maciej Los 255
2 Aajmot Sk 234
3 Richard MacCutchan 200
4 Marcin Kozub 195
0 OriginalGriff 7,903
1 Sergey Alexandrovich Kryukov 7,127
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,820


Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 5 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100