Application requirements change frequently and software is constantly evolving. As a result, such applications often become monolithic making it difficult to add new functionality. Managed Extensibility Framework (MEF) is a new library in .NET Framework 4.0 that addresses this problem by simplifying the design of extensible applications and components.
MEF presents a simple solution for the runtime extensibility problem. Until now, any application that wanted to support a plugin model needed to create its own infrastructure from scratch.
Those plugins would often be application-specific and could not be reused across multiple implementations.
- MEF provides a standard way for the host application to expose itself and consume external extensions. Extensions, by their nature, can be reused amongst different applications. However, an extension could still be implemented in a way that is application-specific. Extensions themselves can depend on one another and MEF will make sure they are wired together in the correct order (another thing you won't have to worry about).
- MEF offers a set of discovery approaches for your application to locate and load available extensions.
- MEF allows tagging extensions with additional metadata which facilitates rich querying and filtering.
New Silverlight API for MEF
And now, you can use MEF with Silverlight. In Silverlight we've introduced a new api called System.ComponentModel.Composition.CompositionInitializer. CompositionInitializer allows parts to get composed by MEF without having to do any manual bootstrapping as it will automatically configure MEF on demand.
This means you can use it anywhere within your Silverlight application.
Series of Screencasts on Channel 9
- Silverlight TV 7: When and Where to use MEF
- MEF & Silverlight 4 Beta - Part 1, Introduction
- MEF & Silverlight 4 Beta - Part 2, Imports & Exports
- MEF & Silverlight 4 Beta - Part 3, Catalogs
- MEF & Silverlight 4 Beta - Part 4, Recomposition
- MEF & Silverlight 4 Beta - Part 5, the PackageCatalog
- MEF & Silverlight 4 Beta - Part 6, Locating Defaults & ExportProviders
Bruce D. Kyle
ISV Architect Evangelist | Microsoft Corporation