5
votes

I have an ASP.Net MVC application that is using NHibernate under the covers for data access. I'm using the Windsor container to handle injecting ISession references into each controller.

This works great, but now I'm looking to expand my application with a pluggable architecture so that I can have a core product and specific add-ons. I found a great article on doing this with MEF.

My question is how to make the Windsor container and MEF container, life/work together so that I can achieve this. There was an article by Glenn Block that talked about this exact issue. Then end then said that the next article would show you how to do this, but there's no part 2.

Has anyone created an application like this using ASP.Net MVC, MEF, NHibernate and Castle Windsor?

3

3 Answers

3
votes

I have spiked small prototype of Windsor->Mef integration 6 months ago here. It is targetting the scenario you seem to be implementing, where you bootstrap your application with Windsor, and want to use MEF for extensibility. You can check it out, perhaps it'll give you some ideas

3
votes

The Who Can Help Me application is using ASP.NET MVC, Castle Windsor and MEF and NHibernate. Worth a look for some ideas.

0
votes

There are more than one possible approaches you might use depending on what you'd like to achieve.

Ditch Windsor in favor of MEF, if possible. If you don't use Windsor's more advanced features, you could easily use MEF instead of Windsor. (Read this post to see if it is suitable for you.)

If you'd like to stick to both of them, read this. (Perhaps this is the same post you mentioned?)

As Glenn wrote, it is perfectly reasonable to have both MEF and Windsor. Here's what I think:

  • Windsor serves as an IoC container for the actual components in your app
  • MEF should be responsible for external components and 3rd party extensions in your app

This should also answer the questions that Glenn raised at the end of his blog post. (And btw, the comments are also worth to read, he says he has a working bridge for Castle.)
Some more stuff you can find in this question.

Hope this helps.