PRESENTATION OUTLINE
The Managed Extensibility Framework or MEF is a library for creating lightweight, extensible applications.
It allows application designers to learn and use extensions with no configuration required.
MEF doesn't just allow extensions to be reused within applications, but also across applications.
the problem of extensibility
Imagine that you are the architect of a large application that must provide support for extensibility. Your application has to include a potentially large number of smaller components, and is responsible for creating and running them.
The simplest approach to the problem is to include the components as source code in your application, and call them directly from your code.
This has a number of obvious drawbacks.
Most importantly, you cannot add new components without modifying the source code, a restriction that might be acceptable in, for example....
A Web application, but is unworkable in a client application.
A slightly more sophisticated approach would be to provide an extension point or interface, to permit decoupling between the application and its components.
Instead of this explicit registration of available components, MEF provides a way to discover them implicitly, via composition.
A MEF component, called a part, declaratively specifies both its dependencies (known as imports) and what capabilities (known as exports) it makes available.
When a part is created, the MEF composition engine satisfies its imports with what is available from other parts.
This approach solves the problems discussed in the previous section. Because MEF parts declaratively specify their capabilities, they are discoverable at runtime, which means an application can make use of parts without either hard-coded references or fragile configuration files.
MEF is an integral part of the .NET Framework 4, and is available wherever the .NET Framework is used.
You can use MEF in your client applications, whether they use Windows Forms, WPF, or any other technology, or in server applications that use ASP.NET.
Previous versions of the .NET Framework introduced the Managed Add-in Framework (MAF), designed to allow applications to isolate and manage extensions.
The focus of MAF is slightly higher-level than MEF, concentrating on extension isolation and assembly loading and unloading, while MEF's focus is on discoverability, extensibility, and portability.
The two frameworks interoperate smoothly, and a single application can take advantage of both.