This project has moved and is read-only. For the latest updates, please go here.

A new MEF release for Windows 8 Metro style apps

May 31, 2012 at 9:18 PM

Hello all,

Today, along with the .NET Framework 4.5 RC, we are delivering a new version of MEF specifically targeting Windows 8 Metro style apps. You can read more about it here:

The new release includes a simplified, streamlined lifetime model and numerous small improvements over the Beta release made some months back. You can review the differences between the Beta and RC versions here:

This release aligns with our earlier experimental work to optimize MEF for web applications, though today's release is specifically targeting Metro style apps (e.g. does not include an updated composition provider for ASP.NET MVC). If you want to use this release with web applications you can view samples in the source code repository on this CodePlex site.

Keep in mind that these changes impact Metro style apps only; the desktop version of MEF in .NET Framework 4.5 RC matches the Beta release.

We're looking forward to your feedback, thanks for checking this out!


Jun 3, 2012 at 5:56 PM

Is there something equivalent to SatisfyImportsOnce?

Jun 5, 2012 at 5:12 PM

Hi there!

Yes - SatisfyImports() is the method to use in this situation, it does not hold references to the passed-in object and so behaves the same way as SatisfyImportsOnce() did in earlier versions.

Note, if you call SatisfyImports() regularly in an application, consider creating a new CompositionContext to do so each time (avoiding reference leaks for disposable parts). E.g.:


public ExportFactory<CompositionContext> ContextFactory { get; set; }

And then to use it:

var context = ContextFactory.CreateExport();


Hope this helps.


Jun 8, 2012 at 6:00 AM

I couldn't find CompositionContext in MEF for Windows 8 Metro. Where is it defined?

Jun 8, 2012 at 4:13 PM

It is in namespace System.Composition, assembly System.Composition.Runtime.dll - let me know if you still have any trouble tracking it down.



Jun 8, 2012 at 5:40 PM

I downloaded "Mef for web and metro style app" 1.0.3-rc (prerelease) from Nuget. I couldn't SatisfyImports method. The only methods are a bunch of GetExport. Is there a newer version?

Jun 8, 2012 at 5:52 PM

SatisfyImports() is an extension method defined in the System.Composition namespace - make sure you have:

using System.Composition;

in the C# file in which you want to use this.



Jun 8, 2012 at 6:02 PM

Ah, thanks a lot. Extension methods have discover issue. Is there any reason why these methods are not moved to CompositionContext class?

Jun 8, 2012 at 6:08 PM

You're welcome. The reason for the factoring is that SatisfyImports() depends on the attributed programming model, while CompositionContext is lower down in the architecture and isn't tied to the attributed model.