Managed Extensibility Framework (MEF)

One of the many announcements made at the PDC was that Visual Studio 10 will be built on top of WPF. In addition, VS will be using MEF as an extensibility mechanism. I just wanted to take a few minutes to explain what MEF is all about.

The Managed Extensibility Framework (MEF) is a library that makes it easy to develop reusable components. The framework provides a standard way for a host application to discover, expose and consume component extensions without the need for each of them to be coupled together.

At the heart of MEF is a ComposablePart, which exposes services or consumes externally provided services. This is done using a Contract, which can be as simple as adding an Import (to consume) or Export (to expose) attribute.

Although MEF is still in development, it already provides a number of key benefits, and would be worth a look if you are, or plan on working on extensible applications. Full source and documentation can be found on CodePlex. It also includes samples, but if there’s interest I’ll add a sample on my blog as a step-by-step walk through.