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

Minor updates in Microsoft.Composition 1.0.13-rc

Jul 20, 2012 at 12:49 AM


We've addressed three minor issues with an update of the Microsoft.Composition (MEF for web and Metro style apps) NuGet package.

We don't expect the changes in this update to the RC will affect the majority of users, but as always please follow up if you would like additional information or help.

Details below:

Import and ImportMany contract type parameter removed

The Import and ImportMany attributes previously allowed a ContractType parameter to be supplied.


                public IFoo Foo { get; set; }

When applied to Lazy<T> or ImportMany imports, the behavior of this parameter changed between MEF (.NET 4.0+) and the Microsoft.Composition package, confusing many users.

In Microsoft.Composition, there are no target scenarios in which this parameter is necessary. So in the interests of streamlining and clarifying usage, it is no longer available on imports:


                public IFoo Foo { get; set; }

Whether a simple, lazy or collection-based import is used, MEF will correctly derive the contract type from the property or parameter type.

Note, this does not affect Export attributes, where the contract type serves a necessary role.

Attribute inheritance rules when ConventionBuilder is applied

Both the container (in its default configuration) and the convention library (when applied) need to take into account various inheritance-related things when scanning for attributes. It was discovered that in some cases, inheritance rules varied between the default configuration and when conventions were applied (see: for details).

Where possible we want to keep the default behavior and the convention behavior lined up, and to match functionality provided by System.ComponentModel.Composition. This update ensures that export attributes (which are not inherited by default) remain non-inherited when conventions are applied.

Removal of the "MetadataViewProvider" extension point and new "Catalog Hosting" sample

To support desktop (MEF in .NET 4.0/4.5 full framework) parts in the new container in conjunction with the Microsoft.Composition.Demos.ComponentModelAttributeSupport sample, the container would query for providers capable of supplying interface-based metadata views using the "MetadataViewProvider" contract. This had the impact of reducing error message quality when unsupported metadata views were used.

In the recent source drop, this sample has been replaced with the more complete Microsoft.Composition.Demos.CatalogHosting sample, which uses MEF catalogs to support a wide range of existing MEF parts with full functionality, including interface-based metadata views.

Since the new catalog hosting approach no longer calls for a metadata view provider extension point, the extension point has been removed, and error messages improved as a result.

Thank you to the MEF community for continuing to use the new package and providing feedback - it has made a huge positive impact so far and we're really happy with the results.

We look forward to hearing more about your experiences using Microsoft.Composition. Thanks again for your continued support.

Nick // the MEF Team