Difference between MEF and IoC containers (like Unity, Autofac, SMap, Ninject, Windsor.Spring.net, etc.)

Eventually what I have concluded about the MEF vs IoC container is as follows:

MEF is preferred to be used when one has to deal with unknown types or a plugin based architecture.

IoC containers are preferred to be used with known types.

Moreover, MEF is an architectural solution for dependency injection

Whereas, IoC containers are code-level solutions for dependency injection.

IoC containers are just dependency injection techniques which populates the instance of a class and if the constructor of those classes requires objects of other classes, then IoC also injects the required objects. But MEF does more than just dependency injection. Although, MEF also uses an IoC-based approach for dependency injection, but MEF does so many other things apart from dependency injection.

MEF has got two components:

  1. Catalog: Is responsible for discovering extension

  2. Container: Provides the ability to load an extension to a running
    application

MEF is more than just dependency injection techniques. It is used wherein we need a plugin-based architecture for our application, but at the same time MEF uses an IoC-based approach for dependency injection.

I am expecting more people to comment on this.

Leave a Comment

tech