Prism 4 and MVVM: Only Unity is suited as a container

Topics: Prism v4 - Silverlight 4, Prism v4 - WPF 4
Jun 13, 2012 at 3:00 PM
Edited Jun 13, 2012 at 3:01 PM


If I'm to develop Silverlight applications using Prism 4 with the MVVM approach, am I forced to use Unity and not MEF?

Jun 13, 2012 at 7:26 PM
Edited Jun 13, 2012 at 7:29 PM


Based on my understanding you should be able to use MEF in your application without problems, as the decision on which dependency injection container you use, will depend mostly on your personal preferences and the requirements of your scenario.

As mentioned in the Prism documentation, when choosing to use the MVVM pattern to construct your application, you may have to make certain design decisions, one of them will be deciding which approach you will use for view and view model construction.

For example, you need to decide whether to use a dependency injection container, such as Unity or MEF. For more information about the different approaches you could use, you could check the following sections of the documentation:

Also, if you are interested in application samples using the MVVM pattern and MEF, I believe you could check for example the MVVM Reference Implementation, or the View-Switching Navigation QuickStart provided with Prism.

Additionally, for more information on how to implement the MVVM pattern, you could find the following resource interesting:

I hope you find this handy,

Agustin Adami

Jun 15, 2012 at 1:59 AM

Hi Agustin:

Thank you for answering.

I installed the "In the Box - MVVM Training" but I don't know what to do then.

What do I have to do in VS to see it?

Getting back to MEF vs Unity, I read this article, it says that "MEF does not work great with MVVM as it will create singleton objects that will behave strangely in runtime and lead to UI failure", and "Unity works best for MVVM, as composing user interface parts can be very easy with unity", this article seemed very serius, it depicted the pros and cons of each container.

Many writers make their examples using MEF and others use Unity, I know that I have to decide, but I don't have the information to make a good decision. As I read MEF will be included in the NET Framework, it tells me that it may be better to use it, but I'll build applications that use Prism, MVVM, RIA Services, SQL Server, Entity Data Framework, Silverlight and WPF. So I need to make a good decision based on what I'll use to avoid having future troubles.

My best regards,


Jun 15, 2012 at 2:00 PM
Edited Jun 15, 2012 at 2:00 PM

Hi Rafael,

Regarding, how to run the "In the Box - MVVM training", once you install it, you have to open Visual Studio 2010; File, New Project, Visual C# and select In the Box, MVVMTraining. Basically you will be creating a new project which will contain all the contents of the training.

Also, as mentioned in its MSDN article, you could find the full and complete information about this training kit in the following link:

On the other hand, regarding the choice of the container you should use, take into account that Prism is container agnostic, meaning that you can use any container you want.

I believe, you could find  more information which may help you in this decision, to determine which container fits your scenario better, in the following chapter of the Prism documentation:

Additionally, you could also find the following threads useful, where similar discussions have been addressed in the past:


Agustin Adami

Jun 15, 2012 at 2:53 PM

Thank you Agustin.

I guess it shouldn't be a hard decision to make since portability between them is easy.