Newbie question: Unity or MEF?

Topics: Prism v4 - Silverlight 4, Prism v4 - WPF 4
Jul 22, 2011 at 9:57 AM


I just finished reading the help dox and developer's guide for PRISM and now I need to choose how to progress. I intend to use PRISM in both SL and WPF, but should I focus on Unity or MEF? Both seem to have capabilities beyond anything I will need, but do they both have a future or is Unity being faced out for MEF, or vice versa? I noticed that MEF is included in .NET 4, does that mean it's considered the way forward?



Jul 22, 2011 at 5:12 PM

Hi Dennis,

As Prism supports both Unity and MEF as containers to perform dependency injection, you could use either of them based on your personal preference. In my opinion, the criteria of which container you should use depends only of the capabilities that your application will require.

You can find more information about the differences between Unity and MEF in the section Key Decision: Choosing a Dependency Injection Container inside Chapter 3: Managing Dependencies Between Components of the Prism documentation.

You might also find this thread helpful, as the subject is discussed in more depth:

MEF or Unity for Prism v4 "Dependency Injection"?

I hope you find this useful.

Guido Leandro Maliandi