Using MEF, MVVM and WCF RIA Services in Silverlight 4


A sample Silverlight business application using MEF, MVVM Light, and WCF RIA Services.


MEF Programming Guide with Silverlight-specific functionality

MEF Programming Guide

  1. Hosting MEF in an application
  2. Defining Parts and Contracts
  3. Declaring Exports
  4. Declaring Imports
  5. Lazy Imports
  6. Exports and Metadata
  7. Using Catalogs
  8. Filtered Catalogs
  9. Part Lifetime
  10. Recomposition
  11. Querying the Composition Container
  12. Composition Batch
  13. Debugging and Diagnostics
  14. FAQ

Silverlight-specific functionality

  1. Hosting MEF in Silverlight using CompositionInitializer
  2. Overriding the default host configuration
  3. Dynamic Instantiation and ExportFactory<T>
  4. Application partitioning with DeploymentCatalog

Also MEF Programming Guide – pdf

Learning MEF in Silverlight 4 and .NET 4

MEF has shipped with Silverlight 4 and with .NET Framework 4.0 and there are versions on CodePlex targeting Silverlight 3 and .NET Framework V3.5 Sp1.

If you’re looking to get started with MEF then here’s some quick resources;

  1. Glenn Block’s new MSDN Magazine Overview Article and Glenn’s Blog
  2. The Overview on CodePlex
  3. The Programming Guide on CodePlex
  4. Mike Taulty’s Channel 9 Videos

but if you’re already up and running then want to know what’s new in the latest drop for the Silverlight developer?

  1. Updated samples!
  2. Renaming and changes to PartInitializer
  3. Renaming and moving of PartCreator
  4. Renaming and changes to CompositionHost.InitializeContainer
  5. A new DeploymentCatalog class, suport dynamically asyn load XAP files on demand!!!

For more check this out:


MEF in Silverlight Screencasts

MEF is a framework that simplifies the design of extensible applications and components. It can flexibly and dynamically discover a set of loosely coupled components and analyse their dependencies in order to compose them together at run time.

Mike Taulty has recently put up a six part series of screencasts covering the use of MEF in Silverlight 4.

Part 1, Introduction

Part 2, Imports & Exports

Part 3, Catalogs

Part 4, Recomposition

Part 5, the PackageCatalog

In Silverlight 4, PackageCatalog has been replaced with DeploymentCatalog. Mike has this screencast showing how to use it. Also check out his blog post here.

Part 6, Locating Defaults & ExportProviders

Another screencast showing how to create a singleton plug-in service shared by a 2 instances of non-shared plug-in.

What Is The Difference Between an IoC Container and MEF?


What Is The Difference Between an IoC Container and MEF?

MEF allows you to write your application as a series of much simpler mini applications, and have those brought together to create a much great whole

IoC container = service level components, MEF = Autonomous Components. A MEF "part" will probably use an IoC container

I recommend reading them highly, they will do a much better job than I could at explaining the detail of the decision points, Should I use MEF for my general IoC needs? and Should I use MEF with an IoC container?

Via What Is The Difference Between an IoC Container and MEF? – Jak Charlton – Insane World – – Just the Tasty Bits

Managed Extensibility Framework


Watch this first: 10mins Screencast

In Silverlight 4 – Glenn Block

Simple Kick Start Example using MEF (Preview 8)

  1. Creating the rule Interface : IRule
  2. Creating a rule instance
  3. Creating the holder for all your plug-ins
  4. Creating the logic to load the plugin
  5. Load Rules at runtime

Also from codeplex:

Learn more about MEF

Read the MEF Programming Guide

Read our sample documentation

Architecture Overview

Visit the MEF Discussions

See our team Blogs

See field and industry blogs on MEF

Read reference documentation on MSDN, (more)