bitbonk
bitbonk

Reputation: 49609

Is MEF a dependency injection framework?

The recently announced managed extensibility framework (MEF) of .NET 4.0 - is it a dependency injection framework? Will Microsoft Unity from Patterns and Practices be obsolete in 4.0 ? How does MEF compare to a framework like Unity?

Upvotes: 31

Views: 16355

Answers (4)

Iti Tyagi
Iti Tyagi

Reputation: 289

I would like to add one mopre line which I have just read that MEF is not a part of Inversion of Control(as dependecny is said to be synonym of IOC) but it implements it. When we implement IOC via dependency injections we generally use Unity, which helps in discovering static dependencies but MEF allows us to increase the extensibility of our application without configuring the components statically, even they can be discovered at run time. There are other links as well which can help you more: Difference between Unity and MEF

Upvotes: 0

Doug
Doug

Reputation: 5338

Here's a conversation about MEF/MAF/Unity/Prism I found enlightening.

Upvotes: 1

Scott Wade
Scott Wade

Reputation: 476

Specifically addressed in the PDC 2008 2nd Keynote by Scott Guthrie, MEF has a lot more to do with things like extending Visual Studio 2008 and other applications, without having to use all the COM and older technologies... A very good demonstration of extending the text edition in VS2008 was shown among other things. Start about an hour and 15 minutes into the 2nd day keynote (http://www.microsoftpdc.com) and you'll get direct information, but basically if you are going to "build an application with built in extensiblity points that can easily be discovered, and which supports discovery of extensions," then MEF is what you want. UNITY is what you want for a high-quality IoC container that does DI as well as the other solutions out there but has great and easy integration with the Enterprise Library.

Regarding Unity in the EL4.0 (now 4.1 -- http://msdn.microsoft.com/en-us/library/dd203099.aspx) its actually a IoC that sits on top of the version 2 ObjectBuilder and the EL4.1 has extensibility points for unifying the configuration of various EL application blocks with Unity.

MEF vs. Unity is like comparing apples to oranges. Some great and specific podcast/webcast(s) that describe UNITY in full are here, which I highly recommend:

DotNetRocks Show #393 http://www.dotnetrocks.com/default.aspx?showNum=393 DNR.tv Show #126 http://www.dnrtv.com/default.aspx?showNum=126

Upvotes: 26

Hamish Smith
Hamish Smith

Reputation: 8181

I saw one write up that made it sound like one but more information (Scott Guthrie at PDC2008[Video/wmv]) made me think it's more than a dependency injection framework. From the sounds of things it can be used for dependency injection but also does more.

Upvotes: 1

Related Questions