views:

1764

answers:

3

It's been said on the blogosphere and by MS themselves that MEF isn't another IoC Container.

Ok...but why? It seems the same to me. Maybe it's not as good as Unity or castle Windsor, but it still fits the definition, doesn't it?

Can anyone explain why MEF isn't an IoC Container like Unity or Castle Windsor?

+3  A: 

The answer from the horses mouth

CVertex
+4  A: 

You should also listen to Glenn Block discussing MEF on Herding Code where he differentiates it from DI/IoC containers:

http://herdingcode.com/?p=28

http://herdingcode.com/?p=31

Kev
+6  A: 

We covered this in a recent hanselminutes episode.

http://www.hanselminutes.com/default.aspx?showID=166

Glenn Block
For those who don't want to listen to the full podcast, this what I think the key thing that Glenn says is: "you use MEF to really manage a set of unknown things, you use IoC Containers to manage a set of known things".From my understanding, MEF is good for "plugin" style scenarios where you don't know (or don't care) what the plugin types will be ahead of time. However, it is not good for loading known types based off a configuration (ie "get me an ILogger" and in the configuration you've specified an AwesomeLogger and therefore you get an AwesomeLogger.)
Daniel Chambers
Daniel, you are absolutely right. When it comes to explicit wiring of types, that is not MEF's strong point. It's doable but you have to jump through many hoops.
Glenn Block