Click here to Skip to main content
13,146,663 members (65,094 online)
Rate this:
Please Sign up or sign in to vote.
See more:
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 7:37am

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.170915.1 | Last Updated 5 Jan 2013
Copyright © CodeProject, 1999-2017
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