<?xml version="1.0"?><?xml-stylesheet type="text/xsl" href="/rss.xsl"?><rss version="2.0"><channel><title>MEF Wiki &amp; Documentation Rss Feed</title><link>http://www.codeplex.com/MEF/Wiki/View.aspx?title=Home</link><description>MEF Wiki Rss Description</description><item><title>New Comment on "Documentation"</title><link>http://mef.codeplex.com/documentation?&amp;ANCHOR#C26140</link><description>Hello, this is a really fas&amp;#173;ci&amp;#173;nat&amp;#173;ing web blog and I have loved read&amp;#173;ing sev&amp;#173;eral of the arti&amp;#173;cles and posts con&amp;#173;tained upon the site, sus&amp;#173;tain the great work and hope to read a lot more excit&amp;#173;ing arti&amp;#173;cles in the time to&amp;#160;come. Thank you so much. &amp;#60;a href&amp;#61;&amp;#34;http&amp;#58;&amp;#47;&amp;#47;vienne.co&amp;#47;tui-xach-thoi-trang&amp;#34; rel&amp;#61;&amp;#34;dofollow&amp;#34;&amp;#62;tui xach thoi trang&amp;#60;&amp;#47;a&amp;#62;</description><author>TomyTeo</author><pubDate>Thu, 10 Jan 2013 10:05:55 GMT</pubDate><guid isPermaLink="false">New Comment on "Documentation" 20130110100555A</guid></item><item><title>New Comment on "Documentation"</title><link>http://mef.codeplex.com/documentation?&amp;ANCHOR#C26139</link><description>Thanks for taking the time to discuss this, I feel strongly about it and love learning more on this topic. If possible, as you gain expertise, would you mind updating your blog with more information&amp;#63; It is extremely helpful for me...thanks http&amp;#58;&amp;#47;&amp;#47;verchini.com&amp;#47;that-lung</description><author>TomyTeo</author><pubDate>Thu, 10 Jan 2013 10:04:17 GMT</pubDate><guid isPermaLink="false">New Comment on "Documentation" 20130110100417A</guid></item><item><title>New Comment on "Microsoft.Composition FAQ"</title><link>http://mef.codeplex.com/wikipage?title=Microsoft.Composition FAQ&amp;ANCHOR#C25992</link><description>Can I Use MEF in my WinForm applications&amp;#63;</description><author>caiqixian</author><pubDate>Fri, 21 Dec 2012 01:03:54 GMT</pubDate><guid isPermaLink="false">New Comment on "Microsoft.Composition FAQ" 20121221010354A</guid></item><item><title>New Comment on "DeploymentCatalog"</title><link>http://mef.codeplex.com/wikipage?title=DeploymentCatalog&amp;ANCHOR#C25724</link><description>I&amp;#39;m getting this issue when I try to reload a xap file using DeploymentCatalog,&amp;#10;the file is reloaded successfully but the re-composition seems to use the old version of the xap file.&amp;#10;&amp;#10;Here is the situation&amp;#58;&amp;#10;&amp;#10;I have a module called ModuleA.xap  that is loaded when a button is clicked on UI.&amp;#10;after the ModuleA.xap is loaded using DeploymentCatalog a list is populated with data that comes from a service defined within ModuleA.xap.&amp;#10;the service has property called Version &amp;#91;String&amp;#93; that&amp;#39;s shows on UI.&amp;#10;&amp;#10;A updated Module.xap package and assigned a new value for Version property.&amp;#10;I clicked the button to reload ModuleA.xap.&amp;#10;After recomposition I still see the old value for Version property. &amp;#33;&amp;#33;&amp;#33;&amp;#33;&amp;#33;&amp;#33;&amp;#10;Through Chrome I see that a request is made and the updated version of ModuleA.xap is loaded.&amp;#10;but when I change the assembly version re-composition fails &amp;#33;&amp;#33;&amp;#33;&amp;#33;&amp;#33;&amp;#33;&amp;#33;&amp;#10;&amp;#10;-Hamid</description><author>mokdes</author><pubDate>Tue, 27 Nov 2012 21:13:49 GMT</pubDate><guid isPermaLink="false">New Comment on "DeploymentCatalog" 20121127091349P</guid></item><item><title>New Comment on "Exports and Metadata"</title><link>http://mef.codeplex.com/wikipage?title=Exports and Metadata&amp;ANCHOR#C25405</link><description>If you allow multiple custom export attributes, keep in mind that in the case of your MyExportWithMetadata &amp;#123; string Metadata &amp;#123;g&amp;#59;s&amp;#125; &amp;#125;, your matching metadata view interface will look like&amp;#58; IMyMetaView &amp;#123; string&amp;#91;&amp;#93; &amp;#123; g&amp;#59; &amp;#125; &amp;#125;.</description><author>mchurchill</author><pubDate>Tue, 30 Oct 2012 01:42:23 GMT</pubDate><guid isPermaLink="false">New Comment on "Exports and Metadata" 20121030014223A</guid></item><item><title>Updated Wiki: Documentation</title><link>http://mef.codeplex.com/documentation?version=20</link><description>&lt;div class="wikidoc"&gt;&lt;h2&gt;Microsoft.Composition&lt;/h2&gt;
Documentation for MEF in web and .NET for Windows Store apps on this site:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;&lt;a href="http://mef.codeplex.com/wikipage?title=What%20is%20Microsoft.Composition%3f&amp;referringTitle=Documentation"&gt;What is Microsoft.Composition&amp;#63;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://mef.codeplex.com/wikipage?title=Sharing%20and%20lifetime&amp;referringTitle=Documentation"&gt;Sharing and lifetime&lt;/a&gt; in Microsoft.Composition&lt;/li&gt;
&lt;li&gt;Extending Microsoft.Composition &lt;a href="http://mef.codeplex.com/wikipage?title=ProgrammingModelExtensions&amp;referringTitle=Documentation"&gt;with alternative programming models&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://mef.codeplex.com/wikipage?title=Avoiding%20reference%20%28memory%29%20leaks%20in%20MEF%20for%20.Net%204.5%20and%20Windows%20Store%20Apps&amp;referringTitle=Documentation"&gt;Avoiding reference &amp;#40;memory&amp;#41; leaks in Microsoft.Composition&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://mef.codeplex.com/wikipage?title=Unit%20Testing%20Microsoft.Composition&amp;referringTitle=Documentation"&gt;Unit Testing Microsoft.Composition&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Creating a &lt;a href="http://mef.codeplex.com/wikipage?title=Standalone%20Web%20API%20dependency%20resolver%20using%20Microsoft.Composition&amp;referringTitle=Documentation"&gt;Standalone Web API dependency resolver using Microsoft.Composition&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;To move code from MEF in the .NET Framework from 4.0 see the &lt;a href="http://mef.codeplex.com/wikipage?title=Changes&amp;referringTitle=Documentation"&gt;migration guide&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://mef.codeplex.com/wikipage?title=Microsoft.Composition%20FAQ&amp;referringTitle=Documentation"&gt;Microsoft.Composition FAQ&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;

&lt;h2&gt;MEF in the .NET Framework (from 4.0)&lt;/h2&gt;
Please see the &lt;a href="http://msdn.microsoft.com/en-us/library/dd460648.aspx"&gt;introductory&lt;/a&gt; and &lt;a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.composition(VS.100).aspx"&gt;reference documentation on MSDN&lt;/a&gt; (&lt;a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.composition.hosting(VS.100).aspx"&gt;more&lt;/a&gt;).&lt;/div&gt;&lt;div class="ClearBoth"&gt;&lt;/div&gt;</description><author>alokshriram</author><pubDate>Thu, 18 Oct 2012 22:28:12 GMT</pubDate><guid isPermaLink="false">Updated Wiki: Documentation 20121018102812P</guid></item><item><title>Updated Wiki: Documentation</title><link>http://mef.codeplex.com/documentation?version=19</link><description>&lt;div class="wikidoc"&gt;&lt;h2&gt;Microsoft.Composition&lt;/h2&gt;
Documentation for MEF in web and .NET for Windows Store apps on this site:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;&lt;a href="http://mef.codeplex.com/wikipage?title=What%20is%20Microsoft.Composition%3f&amp;referringTitle=Documentation"&gt;What is Microsoft.Composition&amp;#63;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://mef.codeplex.com/wikipage?title=Sharing%20and%20lifetime&amp;referringTitle=Documentation"&gt;Sharing and lifetime&lt;/a&gt; in Microsoft.Composition&lt;/li&gt;
&lt;li&gt;Extending Microsoft.Composition &lt;a href="http://mef.codeplex.com/wikipage?title=ProgrammingModelExtensions&amp;referringTitle=Documentation"&gt;with alternative programming models&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://mef.codeplex.com/wikipage?title=Avoiding%20reference%20%28memory%29%20leaks%20in%20MEF%20for%20Windows%20Store%20apps&amp;referringTitle=Documentation"&gt;Avoiding reference &amp;#40;memory&amp;#41; leaks in Microsoft.Composition&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://mef.codeplex.com/wikipage?title=Unit%20Testing%20Microsoft.Composition&amp;referringTitle=Documentation"&gt;Unit Testing Microsoft.Composition&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Creating a &lt;a href="http://mef.codeplex.com/wikipage?title=Standalone%20Web%20API%20dependency%20resolver%20using%20Microsoft.Composition&amp;referringTitle=Documentation"&gt;Standalone Web API dependency resolver using Microsoft.Composition&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;To move code from MEF in the .NET Framework from 4.0 see the &lt;a href="http://mef.codeplex.com/wikipage?title=Changes&amp;referringTitle=Documentation"&gt;migration guide&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://mef.codeplex.com/wikipage?title=Microsoft.Composition%20FAQ&amp;referringTitle=Documentation"&gt;Microsoft.Composition FAQ&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;

&lt;h2&gt;MEF in the .NET Framework (from 4.0)&lt;/h2&gt;
Please see the &lt;a href="http://msdn.microsoft.com/en-us/library/dd460648.aspx"&gt;introductory&lt;/a&gt; and &lt;a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.composition(VS.100).aspx"&gt;reference documentation on MSDN&lt;/a&gt; (&lt;a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.composition.hosting(VS.100).aspx"&gt;more&lt;/a&gt;).&lt;/div&gt;&lt;div class="ClearBoth"&gt;&lt;/div&gt;</description><author>alokshriram</author><pubDate>Thu, 18 Oct 2012 22:26:40 GMT</pubDate><guid isPermaLink="false">Updated Wiki: Documentation 20121018102640P</guid></item><item><title>Updated Wiki: Documentation</title><link>http://mef.codeplex.com/documentation?version=18</link><description>&lt;div class="wikidoc"&gt;&lt;h2&gt;Microsoft.Composition&lt;/h2&gt;
Documentation for MEF in web and .NET for Windows Store apps on this site:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;&lt;a href="http://mef.codeplex.com/wikipage?title=What%20is%20Microsoft.Composition%3f&amp;referringTitle=Documentation"&gt;What is Microsoft.Composition&amp;#63;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://mef.codeplex.com/wikipage?title=Sharing%20and%20lifetime&amp;referringTitle=Documentation"&gt;Sharing and lifetime&lt;/a&gt; in Microsoft.Composition&lt;/li&gt;
&lt;li&gt;Extending Microsoft.Composition &lt;a href="http://mef.codeplex.com/wikipage?title=ProgrammingModelExtensions&amp;referringTitle=Documentation"&gt;with alternative programming models&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://mef.codeplex.com/wikipage?title=Avoiding%20reference%20%28memory%29%20leaks%20in%20MEF%20for%20Metro%20style%20apps&amp;referringTitle=Documentation"&gt;Avoiding reference &amp;#40;memory&amp;#41; leaks in Microsoft.Composition&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://mef.codeplex.com/wikipage?title=Unit%20Testing%20Microsoft.Composition&amp;referringTitle=Documentation"&gt;Unit Testing Microsoft.Composition&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Creating a &lt;a href="http://mef.codeplex.com/wikipage?title=Standalone%20Web%20API%20dependency%20resolver%20using%20Microsoft.Composition&amp;referringTitle=Documentation"&gt;Standalone Web API dependency resolver using Microsoft.Composition&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;To move code from MEF in the .NET Framework from 4.0 see the &lt;a href="http://mef.codeplex.com/wikipage?title=Changes&amp;referringTitle=Documentation"&gt;migration guide&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://mef.codeplex.com/wikipage?title=Microsoft.Composition%20FAQ&amp;referringTitle=Documentation"&gt;Microsoft.Composition FAQ&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;

&lt;h2&gt;MEF in the .NET Framework (from 4.0)&lt;/h2&gt;
Please see the &lt;a href="http://msdn.microsoft.com/en-us/library/dd460648.aspx"&gt;introductory&lt;/a&gt; and &lt;a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.composition(VS.100).aspx"&gt;reference documentation on MSDN&lt;/a&gt; (&lt;a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.composition.hosting(VS.100).aspx"&gt;more&lt;/a&gt;).&lt;/div&gt;&lt;div class="ClearBoth"&gt;&lt;/div&gt;</description><author>alokshriram</author><pubDate>Thu, 18 Oct 2012 18:33:53 GMT</pubDate><guid isPermaLink="false">Updated Wiki: Documentation 20121018063353P</guid></item><item><title>Updated Wiki: MetroChanges</title><link>http://mef.codeplex.com/wikipage?title=MetroChanges&amp;version=3</link><description>&lt;div class="wikidoc"&gt;&lt;h1&gt;MEF for Windows 8 Windows Store apps&lt;/h1&gt;
In .NET 4.5 Beta, Windows 8 Windows Store apps could use a subset of MEF functionality from the full .NET Framework. To better align with the goals and scenarios of Windows Store apps, in .NET 4.5 RC MEF for Windows Store apps is consumed by installing the &lt;i&gt;Microsoft.Composition&lt;/i&gt; package.&lt;br /&gt;&lt;br /&gt;The MEF implementation in &lt;i&gt;Microsoft.Composition&lt;/i&gt; is not code-compatible with the MEF functionality in .NET 4.5 Beta.&lt;br /&gt;&lt;br /&gt;For most applications, a few simple steps will be required to move to the new MEF version. These are outlined step-by-step below. A full list of changes follows.&lt;br /&gt;
&lt;h1&gt;Project-level changes&lt;/h1&gt;
&lt;h2&gt;Referencing the new assemblies&lt;/h2&gt;
The new assemblies are referenced using the Visual Studio Package Manager dialog.&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Right-click on your Windows Store application project&lt;/li&gt;
&lt;li&gt;Select “Manage NuGet Packages”&lt;/li&gt;
&lt;li&gt;Select “Include Prerelease Packages”&lt;/li&gt;
&lt;li&gt;Search for Microsoft.Composition&lt;/li&gt;
&lt;li&gt;Click “Install”&lt;/li&gt;&lt;/ol&gt;
&lt;br /&gt;Alternatively, the Package Manager Console can be used:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;
Install-Package Microsoft.Composition –Pre&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Delivering MEF as a NuGet package enables a more responsive development process.&lt;br /&gt;
&lt;h2&gt;Namespace change&lt;/h2&gt;
Use Visuals Studio’s Find and Replace in Files dialog to replace the text:&lt;br /&gt;&lt;br /&gt;&lt;span class="codeInline"&gt;System.ComponentModel.Composition&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;with:&lt;br /&gt;&lt;br /&gt;&lt;span class="codeInline"&gt;System.Composition&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;b&gt;Rationale:&lt;/b&gt; MEF for Windows Store apps is optimized for this model and therefore makes changes to some fundamental MEF types like &lt;span class="codeInline"&gt;[Import]&lt;/span&gt; and &lt;span class="codeInline"&gt;[Export]&lt;/span&gt;. Changing the namespace ensures that types can be uniquely identified and correct information can be found more easily.&lt;/i&gt;&lt;br /&gt;
&lt;h1&gt;Part-level changes&lt;/h1&gt;
&lt;h2&gt;Import/Export visibility&lt;/h2&gt;
Imported and exported members must be publicly visible in order for them to be composed. For example:&lt;br /&gt;&lt;br /&gt;&lt;div style="color:Black;background-color:White;"&gt;&lt;pre&gt;
    [Import]
    &lt;span style="color:Blue;"&gt;private&lt;/span&gt; ILogger Logger { &lt;span style="color:Blue;"&gt;get&lt;/span&gt;; &lt;span style="color:Blue;"&gt;set&lt;/span&gt;; }
&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;Must be updated to:&lt;br /&gt;&lt;br /&gt;&lt;div style="color:Black;background-color:White;"&gt;&lt;pre&gt;
    [Import]
    &lt;span style="color:Blue;"&gt;public&lt;/span&gt; ILogger Logger { &lt;span style="color:Blue;"&gt;get&lt;/span&gt;; &lt;span style="color:Blue;"&gt;set&lt;/span&gt;; }
&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;The same is true of importing constructors and property exports.&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;b&gt;Rationale:&lt;/b&gt; Requiring that imports and exports are public ensures that parts behave consistently on all platforms, and that code generation techniques can be used to improve throughput.&lt;/i&gt;&lt;br /&gt;
&lt;h3&gt;Unsupported features&lt;/h3&gt;
Field exports and imports are not supported – use property imports and exports instead.&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;b&gt;Rationale:&lt;/b&gt; Due to the requirement for public imports and exports, fields are less useful for this purpose. Ignoring them improves startup time for the composition engine.&lt;/i&gt;&lt;br /&gt;
&lt;h2&gt;Part creation policy&lt;/h2&gt;
&lt;span class="codeInline"&gt;[PartCreationPolicy(CreationPolicy.NonShared)]&lt;/span&gt; is no longer required, as parts are non-shared by default.&lt;br /&gt;&lt;br /&gt;Parts that need to be shared are marked with the &lt;span class="codeInline"&gt;[Shared]&lt;/span&gt; attribute.&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;b&gt;Rationale:&lt;/b&gt; The default creation policy was previously &lt;span class="codeInline"&gt;CreationPolicy.Any&lt;/span&gt;, making it confusing to determine the scope in which a part could be used. Sharing and lifetime have been streamlined so that the sharing scope of a part is always explicitly visible – a part marked &lt;span class="codeInline"&gt;[Shared]&lt;/span&gt; will always be globally shared; a part marked &lt;span class="codeInline"&gt;[Shared(&amp;quot;vm&amp;quot;)]&lt;/span&gt; will always be shared within the named boundary “vm”, parts without an annotation are always non-shared. See also: &lt;span class="codeInline"&gt;[SharingBoundary]&lt;/span&gt; and &lt;span class="codeInline"&gt;ExportFactory&amp;lt;T&amp;gt;&lt;/span&gt;.&lt;/i&gt;&lt;br /&gt;
&lt;h2&gt;IPartImportsSatisfiedNotification&lt;/h2&gt;
This interface has been replaced with the &lt;a href="http://mef.codeplex.com/wikipage?title=OnImportsSatisfied&amp;referringTitle=MetroChanges"&gt;OnImportsSatisfied&lt;/a&gt; attribute.&lt;br /&gt;&lt;br /&gt;For example, the following part:&lt;br /&gt;&lt;br /&gt;&lt;div style="color:Black;background-color:White;"&gt;&lt;pre&gt;
    [Export]
    &lt;span style="color:Blue;"&gt;public&lt;/span&gt; &lt;span style="color:Blue;"&gt;class&lt;/span&gt; APart : IPartImportsSatisfiedNotification
    {
        &lt;span style="color:Blue;"&gt;public&lt;/span&gt; &lt;span style="color:Blue;"&gt;void&lt;/span&gt; OnImportsSatisfied() { }
    }
&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;Can be rewritten as:&lt;br /&gt;&lt;br /&gt;&lt;div style="color:Black;background-color:White;"&gt;&lt;pre&gt;
    [Export]
    &lt;span style="color:Blue;"&gt;public&lt;/span&gt; &lt;span style="color:Blue;"&gt;class&lt;/span&gt; APart 
    {
        [OnImportsSatisfied]
        &lt;span style="color:Blue;"&gt;public&lt;/span&gt; &lt;span style="color:Blue;"&gt;void&lt;/span&gt; OnImportsSatisfied() { }
    }
&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;i&gt;&lt;b&gt;Rationale:&lt;/b&gt; MEF’s convention support is based on attributes. By marking the OnImportsSatisfied() method with an attribute, conventions can select this method. This was not possible with the interface-based approach.&lt;/i&gt;&lt;br /&gt;
&lt;h2&gt;Format of Metadata Views&lt;/h2&gt;
Metadata views must be concrete types rather than interfaces. For example, the metadata view:&lt;br /&gt;&lt;br /&gt;&lt;div style="color:Black;background-color:White;"&gt;&lt;pre&gt;
    &lt;span style="color:Blue;"&gt;public&lt;/span&gt; &lt;span style="color:Blue;"&gt;interface&lt;/span&gt; INamed
    {
        &lt;span style="color:Blue;"&gt;string&lt;/span&gt; Name { &lt;span style="color:Blue;"&gt;get&lt;/span&gt;; &lt;span style="color:Blue;"&gt;set&lt;/span&gt;; }
    }
&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;Can be rewritten as:&lt;br /&gt;&lt;br /&gt;&lt;div style="color:Black;background-color:White;"&gt;&lt;pre&gt;
    &lt;span style="color:Blue;"&gt;public&lt;/span&gt; &lt;span style="color:Blue;"&gt;class&lt;/span&gt; Named
    {
        &lt;span style="color:Blue;"&gt;public&lt;/span&gt; &lt;span style="color:Blue;"&gt;string&lt;/span&gt; Name { &lt;span style="color:Blue;"&gt;get&lt;/span&gt;; &lt;span style="color:Blue;"&gt;set&lt;/span&gt;; }
    }
&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;i&gt;&lt;b&gt;Rationale:&lt;/b&gt; This requirement arises from the absence of the System.Reflection.Emit namespace in .NET for Windows Store apps. Without the functionality in this namespace, metadata views based on interfaces cannot be generated.&lt;/i&gt;&lt;br /&gt;
&lt;h1&gt;Hosting changes&lt;/h1&gt;
&lt;h2&gt;Container configuration&lt;/h2&gt;
On the hosting side, a smaller API with fewer configuration points is presented. Assemblies and part types are added to a ContainerConfiguration (rather than a catalog) and from there a container can be created and exports requested.&lt;br /&gt;&lt;br /&gt;&lt;div style="color:Black;background-color:White;"&gt;&lt;pre&gt;
    &lt;span style="color:Blue;"&gt;var&lt;/span&gt; configuration = &lt;span style="color:Blue;"&gt;new&lt;/span&gt; ContainerConfiguration()
                        .WithAssembly(&lt;span style="color:Blue;"&gt;typeof&lt;/span&gt;(App).GetTypeInfo().Assembly);

    &lt;span style="color:Blue;"&gt;using&lt;/span&gt; (&lt;span style="color:Blue;"&gt;var&lt;/span&gt; container = configuration.CreateContainer())
    {
        &lt;span style="color:Blue;"&gt;var&lt;/span&gt; handler = container.GetExport&amp;lt;IMessageHandler&amp;gt;();
        handler.Handle(message);
    }
&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;The &lt;span class="codeInline"&gt;ContainerConfiguration&lt;/span&gt; class provides a method-chaining API to add types and assemblies to the container. There is no catalog concept, nor composition batches, nor any “container hierarchy” or composition scoping APIs.&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;b&gt;Rationale:&lt;/b&gt; The hosting APIs used in MEF in the full .NET Framework are designed to support open, extensible applications. This functionality is not required in Windows Store apps, and so the developer experience is simplified.&lt;/i&gt;&lt;br /&gt;
&lt;h2&gt;Conventions and RegistrationBuilder&lt;/h2&gt;
In .NET 4.5 MEF introduces the &lt;span class="codeInline"&gt;RegistrationBuilder&lt;/span&gt; class. On Windows Store apps the same functionality is available via &lt;span class="codeInline"&gt;ConventionBuilder&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;b&gt;Rationale:&lt;/b&gt; ConventionBuilder is expected to evolve significantly in conjunction with the MEF implementation for Windows Store apps. Retaining the &lt;span class="codeInline"&gt;RegistrationBuilder&lt;/span&gt; name would make these differences confusing.&lt;/i&gt;&lt;br /&gt;
&lt;h1&gt;MEF in Windows Store apps vs. .NET Framework&lt;/h1&gt;
The table below summarizes high-level feature compatibility across MEF for Windows Store apps and the full framework.&lt;br /&gt;&lt;br /&gt;&lt;table&gt;&lt;tr&gt;&lt;th&gt;Functionality&lt;/th&gt;&lt;th&gt;Windows Store apps&lt;/th&gt;&lt;th&gt;Full&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Catalogs&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Recomposition&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Rejection&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Instance Exports&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Static Exports&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Property Exports&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Field Exports&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Importing Constructors&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Property Imports&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Field Imports&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Method Exports&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Internal Part Types&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Non Public Imports/Exports&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Export Metadata&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Import Metadata Views&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Part Metadata&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Nested Containers&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Composition Scope Definition&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Lazy Imports&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;ExportFactory Imports&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Import Many&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Import Custom Collections&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Contract Names&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Import Sources&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Cyclic Dependencies&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Open Generics&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;IPartImportsSatisfiedNotification&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Import Required Creation Policy&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Interface Metadata Views&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Concrete Metadata View s&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Missing Metadata Ignored&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Inherited Exports&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;PartCreationPolicyAttribute&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;CatalogReflectionContextAttribute&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;MetadataAttributeAttribute&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;PartNotDiscoverableAttribute&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;ICompositionService&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;CompositionOptions&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class="ClearBoth"&gt;&lt;/div&gt;</description><author>alokshriram</author><pubDate>Thu, 18 Oct 2012 18:33:34 GMT</pubDate><guid isPermaLink="false">Updated Wiki: MetroChanges 20121018063334P</guid></item><item><title>Updated Wiki: Changes</title><link>http://mef.codeplex.com/wikipage?title=Changes&amp;version=1</link><description>&lt;div class="wikidoc"&gt;&lt;h1&gt;MEF for Windows 8 Windows Store apps&lt;/h1&gt;
In .NET 4.5 Beta, Windows 8 Windows Store apps could use a subset of MEF functionality from the full .NET Framework. To better align with the goals and scenarios of Windows Store apps, in .NET 4.5 RC MEF for Windows Store apps is consumed by installing the &lt;i&gt;Microsoft.Composition&lt;/i&gt; package.&lt;br /&gt;&lt;br /&gt;The MEF implementation in &lt;i&gt;Microsoft.Composition&lt;/i&gt; is not code-compatible with the MEF functionality in .NET 4.5 Beta.&lt;br /&gt;&lt;br /&gt;For most applications, a few simple steps will be required to move to the new MEF version. These are outlined step-by-step below. A full list of changes follows.&lt;br /&gt;
&lt;h1&gt;Project-level changes&lt;/h1&gt;
&lt;h2&gt;Referencing the new assemblies&lt;/h2&gt;
The new assemblies are referenced using the Visual Studio Package Manager dialog.&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Right-click on your Windows Store application project&lt;/li&gt;
&lt;li&gt;Select “Manage NuGet Packages”&lt;/li&gt;
&lt;li&gt;Select “Include Prerelease Packages”&lt;/li&gt;
&lt;li&gt;Search for Microsoft.Composition&lt;/li&gt;
&lt;li&gt;Click “Install”&lt;/li&gt;&lt;/ol&gt;
&lt;br /&gt;Alternatively, the Package Manager Console can be used:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;
Install-Package Microsoft.Composition –Pre&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Delivering MEF as a NuGet package enables a more responsive development process.&lt;br /&gt;
&lt;h2&gt;Namespace change&lt;/h2&gt;
Use Visuals Studio’s Find and Replace in Files dialog to replace the text:&lt;br /&gt;&lt;br /&gt;&lt;span class="codeInline"&gt;System.ComponentModel.Composition&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;with:&lt;br /&gt;&lt;br /&gt;&lt;span class="codeInline"&gt;System.Composition&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;b&gt;Rationale:&lt;/b&gt; MEF for Windows Store apps is optimized for this model and therefore makes changes to some fundamental MEF types like &lt;span class="codeInline"&gt;[Import]&lt;/span&gt; and &lt;span class="codeInline"&gt;[Export]&lt;/span&gt;. Changing the namespace ensures that types can be uniquely identified and correct information can be found more easily.&lt;/i&gt;&lt;br /&gt;
&lt;h1&gt;Part-level changes&lt;/h1&gt;
&lt;h2&gt;Import/Export visibility&lt;/h2&gt;
Imported and exported members must be publicly visible in order for them to be composed. For example:&lt;br /&gt;&lt;br /&gt;&lt;div style="color:Black;background-color:White;"&gt;&lt;pre&gt;
    [Import]
    &lt;span style="color:Blue;"&gt;private&lt;/span&gt; ILogger Logger { &lt;span style="color:Blue;"&gt;get&lt;/span&gt;; &lt;span style="color:Blue;"&gt;set&lt;/span&gt;; }
&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;Must be updated to:&lt;br /&gt;&lt;br /&gt;&lt;div style="color:Black;background-color:White;"&gt;&lt;pre&gt;
    [Import]
    &lt;span style="color:Blue;"&gt;public&lt;/span&gt; ILogger Logger { &lt;span style="color:Blue;"&gt;get&lt;/span&gt;; &lt;span style="color:Blue;"&gt;set&lt;/span&gt;; }
&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;The same is true of importing constructors and property exports.&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;b&gt;Rationale:&lt;/b&gt; Requiring that imports and exports are public ensures that parts behave consistently on all platforms, and that code generation techniques can be used to improve throughput.&lt;/i&gt;&lt;br /&gt;
&lt;h3&gt;Unsupported features&lt;/h3&gt;
Field exports and imports are not supported – use property imports and exports instead.&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;b&gt;Rationale:&lt;/b&gt; Due to the requirement for public imports and exports, fields are less useful for this purpose. Ignoring them improves startup time for the composition engine.&lt;/i&gt;&lt;br /&gt;
&lt;h2&gt;Part creation policy&lt;/h2&gt;
&lt;span class="codeInline"&gt;[PartCreationPolicy(CreationPolicy.NonShared)]&lt;/span&gt; is no longer required, as parts are non-shared by default.&lt;br /&gt;&lt;br /&gt;Parts that need to be shared are marked with the &lt;span class="codeInline"&gt;[Shared]&lt;/span&gt; attribute.&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;b&gt;Rationale:&lt;/b&gt; The default creation policy was previously &lt;span class="codeInline"&gt;CreationPolicy.Any&lt;/span&gt;, making it confusing to determine the scope in which a part could be used. Sharing and lifetime have been streamlined so that the sharing scope of a part is always explicitly visible – a part marked &lt;span class="codeInline"&gt;[Shared]&lt;/span&gt; will always be globally shared; a part marked &lt;span class="codeInline"&gt;[Shared(&amp;quot;vm&amp;quot;)]&lt;/span&gt; will always be shared within the named boundary “vm”, parts without an annotation are always non-shared. See also: &lt;span class="codeInline"&gt;[SharingBoundary]&lt;/span&gt; and &lt;span class="codeInline"&gt;ExportFactory&amp;lt;T&amp;gt;&lt;/span&gt;.&lt;/i&gt;&lt;br /&gt;
&lt;h2&gt;IPartImportsSatisfiedNotification&lt;/h2&gt;
This interface has been replaced with the &lt;a href="http://mef.codeplex.com/wikipage?title=OnImportsSatisfied&amp;referringTitle=Changes"&gt;OnImportsSatisfied&lt;/a&gt; attribute.&lt;br /&gt;&lt;br /&gt;For example, the following part:&lt;br /&gt;&lt;br /&gt;&lt;div style="color:Black;background-color:White;"&gt;&lt;pre&gt;
    [Export]
    &lt;span style="color:Blue;"&gt;public&lt;/span&gt; &lt;span style="color:Blue;"&gt;class&lt;/span&gt; APart : IPartImportsSatisfiedNotification
    {
        &lt;span style="color:Blue;"&gt;public&lt;/span&gt; &lt;span style="color:Blue;"&gt;void&lt;/span&gt; OnImportsSatisfied() { }
    }
&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;Can be rewritten as:&lt;br /&gt;&lt;br /&gt;&lt;div style="color:Black;background-color:White;"&gt;&lt;pre&gt;
    [Export]
    &lt;span style="color:Blue;"&gt;public&lt;/span&gt; &lt;span style="color:Blue;"&gt;class&lt;/span&gt; APart 
    {
        [OnImportsSatisfied]
        &lt;span style="color:Blue;"&gt;public&lt;/span&gt; &lt;span style="color:Blue;"&gt;void&lt;/span&gt; OnImportsSatisfied() { }
    }
&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;i&gt;&lt;b&gt;Rationale:&lt;/b&gt; MEF’s convention support is based on attributes. By marking the OnImportsSatisfied() method with an attribute, conventions can select this method. This was not possible with the interface-based approach.&lt;/i&gt;&lt;br /&gt;
&lt;h2&gt;Format of Metadata Views&lt;/h2&gt;
Metadata views must be concrete types rather than interfaces. For example, the metadata view:&lt;br /&gt;&lt;br /&gt;&lt;div style="color:Black;background-color:White;"&gt;&lt;pre&gt;
    &lt;span style="color:Blue;"&gt;public&lt;/span&gt; &lt;span style="color:Blue;"&gt;interface&lt;/span&gt; INamed
    {
        &lt;span style="color:Blue;"&gt;string&lt;/span&gt; Name { &lt;span style="color:Blue;"&gt;get&lt;/span&gt;; &lt;span style="color:Blue;"&gt;set&lt;/span&gt;; }
    }
&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;Can be rewritten as:&lt;br /&gt;&lt;br /&gt;&lt;div style="color:Black;background-color:White;"&gt;&lt;pre&gt;
    &lt;span style="color:Blue;"&gt;public&lt;/span&gt; &lt;span style="color:Blue;"&gt;class&lt;/span&gt; Named
    {
        &lt;span style="color:Blue;"&gt;public&lt;/span&gt; &lt;span style="color:Blue;"&gt;string&lt;/span&gt; Name { &lt;span style="color:Blue;"&gt;get&lt;/span&gt;; &lt;span style="color:Blue;"&gt;set&lt;/span&gt;; }
    }
&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;i&gt;&lt;b&gt;Rationale:&lt;/b&gt; This requirement arises from the absence of the System.Reflection.Emit namespace in .NET for Windows Store apps. Without the functionality in this namespace, metadata views based on interfaces cannot be generated.&lt;/i&gt;&lt;br /&gt;
&lt;h1&gt;Hosting changes&lt;/h1&gt;
&lt;h2&gt;Container configuration&lt;/h2&gt;
On the hosting side, a smaller API with fewer configuration points is presented. Assemblies and part types are added to a ContainerConfiguration (rather than a catalog) and from there a container can be created and exports requested.&lt;br /&gt;&lt;br /&gt;&lt;div style="color:Black;background-color:White;"&gt;&lt;pre&gt;
    &lt;span style="color:Blue;"&gt;var&lt;/span&gt; configuration = &lt;span style="color:Blue;"&gt;new&lt;/span&gt; ContainerConfiguration()
                        .WithAssembly(&lt;span style="color:Blue;"&gt;typeof&lt;/span&gt;(App).GetTypeInfo().Assembly);

    &lt;span style="color:Blue;"&gt;using&lt;/span&gt; (&lt;span style="color:Blue;"&gt;var&lt;/span&gt; container = configuration.CreateContainer())
    {
        &lt;span style="color:Blue;"&gt;var&lt;/span&gt; handler = container.GetExport&amp;lt;IMessageHandler&amp;gt;();
        handler.Handle(message);
    }
&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;The &lt;span class="codeInline"&gt;ContainerConfiguration&lt;/span&gt; class provides a method-chaining API to add types and assemblies to the container. There is no catalog concept, nor composition batches, nor any “container hierarchy” or composition scoping APIs.&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;b&gt;Rationale:&lt;/b&gt; The hosting APIs used in MEF in the full .NET Framework are designed to support open, extensible applications. This functionality is not required in Windows Store apps, and so the developer experience is simplified.&lt;/i&gt;&lt;br /&gt;
&lt;h2&gt;Conventions and RegistrationBuilder&lt;/h2&gt;
In .NET 4.5 MEF introduces the &lt;span class="codeInline"&gt;RegistrationBuilder&lt;/span&gt; class. On Windows Store apps the same functionality is available via &lt;span class="codeInline"&gt;ConventionBuilder&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;b&gt;Rationale:&lt;/b&gt; ConventionBuilder is expected to evolve significantly in conjunction with the MEF implementation for Windows Store apps. Retaining the &lt;span class="codeInline"&gt;RegistrationBuilder&lt;/span&gt; name would make these differences confusing.&lt;/i&gt;&lt;br /&gt;
&lt;h1&gt;MEF in Windows Store apps vs. .NET Framework&lt;/h1&gt;
The table below summarizes high-level feature compatibility across MEF for Windows Store apps and the full framework.&lt;br /&gt;&lt;br /&gt;&lt;table&gt;&lt;tr&gt;&lt;th&gt;Functionality&lt;/th&gt;&lt;th&gt;Windows Store apps&lt;/th&gt;&lt;th&gt;Full&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Catalogs&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Recomposition&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Rejection&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Instance Exports&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Static Exports&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Property Exports&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Field Exports&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Importing Constructors&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Property Imports&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Field Imports&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Method Exports&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Internal Part Types&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Non Public Imports/Exports&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Export Metadata&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Import Metadata Views&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Part Metadata&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Nested Containers&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Composition Scope Definition&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Lazy Imports&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;ExportFactory Imports&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Import Many&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Import Custom Collections&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Contract Names&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Import Sources&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Cyclic Dependencies&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Open Generics&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;IPartImportsSatisfiedNotification&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Import Required Creation Policy&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Interface Metadata Views&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Concrete Metadata View s&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Missing Metadata Ignored&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Inherited Exports&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;PartCreationPolicyAttribute&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;CatalogReflectionContextAttribute&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;MetadataAttributeAttribute&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;PartNotDiscoverableAttribute&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;ICompositionService&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;CompositionOptions&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class="ClearBoth"&gt;&lt;/div&gt;</description><author>alokshriram</author><pubDate>Thu, 18 Oct 2012 18:33:27 GMT</pubDate><guid isPermaLink="false">Updated Wiki: Changes 20121018063327P</guid></item><item><title>Updated Wiki: Avoiding reference (memory) leaks in MEF for Metro style apps</title><link>http://mef.codeplex.com/wikipage?title=Avoiding reference (memory) leaks in MEF for Metro style apps&amp;version=4</link><description>&lt;div class="wikidoc"&gt;All versions of MEF implement some level of tracking of the parts that the composition engine creates. In MEF for Windows Store apps (&lt;i&gt;System.Composition&lt;/i&gt; namespaces) this is for the purpose of ensuring that disposable parts can be released properly.&lt;br /&gt;&lt;br /&gt;To avoid holding on to part instances for longer than is required, the following guidance applies.&lt;br /&gt;&lt;br /&gt;Where multiple instances of a part need to be created, use an &lt;i&gt;ExportFactory&amp;lt;T&amp;gt;&lt;/i&gt; rather than calling &lt;i&gt;GetExports()&lt;/i&gt; multiple times on the container.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;This code may leak memory.&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;
// Within the class declaration of a part
CompositionContext _container = ...;


// If page objects have disposable dependencies,
// they will be tracked by _container.
public Page CreatePage()
{
    _container.GetExport&amp;lt;Page&amp;gt;();
}
&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;Creating a page: this code does not leak.&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;
// Within the class declaration of a part

[Import]
public ExportFactory&amp;lt;Page&amp;gt; PageFactory { get; set; }

public Page CreatePage()
{
   return PageFactory.CreateExport().Value;
}
&lt;/pre&gt;&lt;br /&gt;If the &lt;i&gt;Export&amp;lt;T&amp;gt;&lt;/i&gt; instance is garbage collected, all collectible parts will also be free for collection (regardless of whether or not &lt;i&gt;Dispose()&lt;/i&gt; is called).&lt;br /&gt;&lt;br /&gt;The &lt;i&gt;Export&amp;lt;T&amp;gt;&lt;/i&gt; instance returned from the &lt;i&gt;CreateExport()&lt;/i&gt; method can be disposed in order to dispose related parts:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;
public void ShowPage()
{
   using (var page = PageFactory.CreateExport())
   {
      // Outside the using block, the page and its dependencies
      // will be disposed.
      page.Value.Show();
   }
}
&lt;/pre&gt;&lt;br /&gt;If you need to use &lt;i&gt;CompositionContext&lt;/i&gt; (rather than &lt;i&gt;ExportFactory&amp;lt;T&amp;gt;&lt;/i&gt;) for some reason, e.g. to implement a service locator, then use &lt;i&gt;ExportFactory&amp;lt;CompositionContext&amp;gt;&lt;/i&gt; to create a new &lt;i&gt;CompositionContext&lt;/i&gt; for each unit of work.&lt;br /&gt;&lt;br /&gt;This applies when using &lt;i&gt;CompositionContext.SatisfyImports()&lt;/i&gt; as well.&lt;br /&gt;&lt;/div&gt;&lt;div class="ClearBoth"&gt;&lt;/div&gt;</description><author>alokshriram</author><pubDate>Thu, 18 Oct 2012 18:29:51 GMT</pubDate><guid isPermaLink="false">Updated Wiki: Avoiding reference (memory) leaks in MEF for Metro style apps 20121018062951P</guid></item><item><title>Updated Wiki: Avoiding reference (memory) leaks in MEF for .Net 4.5 and Windows Store Apps</title><link>http://mef.codeplex.com/wikipage?title=Avoiding reference (memory) leaks in MEF for .Net 4.5 and Windows Store Apps&amp;version=1</link><description>&lt;div class="wikidoc"&gt;All versions of MEF implement some level of tracking of the parts that the composition engine creates. In MEF for Windows Store apps (&lt;i&gt;System.Composition&lt;/i&gt; namespaces) this is for the purpose of ensuring that disposable parts can be released properly.&lt;br /&gt;&lt;br /&gt;To avoid holding on to part instances for longer than is required, the following guidance applies.&lt;br /&gt;&lt;br /&gt;Where multiple instances of a part need to be created, use an &lt;i&gt;ExportFactory&amp;lt;T&amp;gt;&lt;/i&gt; rather than calling &lt;i&gt;GetExports()&lt;/i&gt; multiple times on the container.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;This code may leak memory.&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;
// Within the class declaration of a part
CompositionContext _container = ...;


// If page objects have disposable dependencies,
// they will be tracked by _container.
public Page CreatePage()
{
    _container.GetExport&amp;lt;Page&amp;gt;();
}
&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;Creating a page: this code does not leak.&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;
// Within the class declaration of a part

[Import]
public ExportFactory&amp;lt;Page&amp;gt; PageFactory { get; set; }

public Page CreatePage()
{
   return PageFactory.CreateExport().Value;
}
&lt;/pre&gt;&lt;br /&gt;If the &lt;i&gt;Export&amp;lt;T&amp;gt;&lt;/i&gt; instance is garbage collected, all collectible parts will also be free for collection (regardless of whether or not &lt;i&gt;Dispose()&lt;/i&gt; is called).&lt;br /&gt;&lt;br /&gt;The &lt;i&gt;Export&amp;lt;T&amp;gt;&lt;/i&gt; instance returned from the &lt;i&gt;CreateExport()&lt;/i&gt; method can be disposed in order to dispose related parts:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;
public void ShowPage()
{
   using (var page = PageFactory.CreateExport())
   {
      // Outside the using block, the page and its dependencies
      // will be disposed.
      page.Value.Show();
   }
}
&lt;/pre&gt;&lt;br /&gt;If you need to use &lt;i&gt;CompositionContext&lt;/i&gt; (rather than &lt;i&gt;ExportFactory&amp;lt;T&amp;gt;&lt;/i&gt;) for some reason, e.g. to implement a service locator, then use &lt;i&gt;ExportFactory&amp;lt;CompositionContext&amp;gt;&lt;/i&gt; to create a new &lt;i&gt;CompositionContext&lt;/i&gt; for each unit of work.&lt;br /&gt;&lt;br /&gt;This applies when using &lt;i&gt;CompositionContext.SatisfyImports()&lt;/i&gt; as well.&lt;br /&gt;&lt;/div&gt;&lt;div class="ClearBoth"&gt;&lt;/div&gt;</description><author>alokshriram</author><pubDate>Thu, 18 Oct 2012 18:29:25 GMT</pubDate><guid isPermaLink="false">Updated Wiki: Avoiding reference (memory) leaks in MEF for .Net 4.5 and Windows Store Apps 20121018062925P</guid></item><item><title>Updated Wiki: Standalone Web API dependency resolver using Microsoft.Composition</title><link>http://mef.codeplex.com/wikipage?title=Standalone Web API dependency resolver using Microsoft.Composition&amp;version=5</link><description>&lt;div class="wikidoc"&gt;&lt;h1&gt;Creating a self-host dependency resolver for ASP.NET Web API using Microsoft.Composition&lt;/h1&gt;
ASP.NET Web API’s &lt;span class="codeInline"&gt;IDependencyResolver&lt;/span&gt; interface allows &lt;span class="codeInline"&gt;IHttpController&lt;/span&gt;s to accept dependencies using dependency injection. By plugging in MEF via this interface, controllers can import their dependencies using the familiar techniques of constructor and property injection.&lt;br /&gt;&lt;br /&gt;This page describes the creation and usage of an &lt;span class="codeInline"&gt;IDependencyResolver&lt;/span&gt; based on the &lt;i&gt;Microsoft.Composition&lt;/i&gt; NuGet package. Source code from the example is in the &lt;i&gt;/oob/src/System.Composition.Web.Http&lt;/i&gt; folder in the source code repository on this site.&lt;br /&gt;
&lt;h2&gt;IDependencyScope&lt;/h2&gt;
Web API requests exports (which it calls &amp;#39;services&amp;#39;) from an &lt;span class="codeInline"&gt;IDependencyScope&lt;/span&gt;. The dependency scope can be used to control sharing on a per-API-call basis, and allows parts to be disposed when no longer required by Web API.&lt;br /&gt;&lt;br /&gt;We call this a “standalone” dependency resolver because it is intended for use in self-hosting scenarios; when using Web API with ASP.NET MVC it may be preferable to bridge the Web API dependency resolver across to the MVC one.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;    public class StandaloneDependencyScope : IDependencyScope
    {
&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;MEF for web and Windows Store apps uses composition contexts to represent scopes. To allow the scope to be disposed when no longer required by Web API, an &lt;span class="codeInline"&gt;Export&amp;lt;CompositionContext&amp;gt;&lt;/span&gt; is used:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;        readonly Export&amp;lt;CompositionContext&amp;gt; _compositionScope;

        public StandaloneDependencyScope(Export&amp;lt;CompositionContext&amp;gt; compositionScope)
        {
            if (compositionScope == null) throw new ArgumentNullException(&amp;quot;compositionScope&amp;quot;);
            _compositionScope = compositionScope;
        }

        protected CompositionContext CompositionScope { get { return _compositionScope.Value; } }

        public void Dispose()
        {
            Dispose(true);
        }

        protected void Dispose(bool disposing)
        {
            if (disposing)
                _compositionScope.Dispose();
        }
&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Web API uses two methods – &lt;span class="codeInline"&gt;GetService()&lt;/span&gt; and &lt;span class="codeInline"&gt;GetServices()&lt;/span&gt; – to request exports from the scope. Rather than throwing on failure, Web API requires that we return &lt;span class="codeInline"&gt;null&lt;/span&gt; if a service is unavailable:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;        public object GetService(Type serviceType)
        {
            if (serviceType == null) throw new ArgumentNullException(&amp;quot;serviceType&amp;quot;);

            object result;
            CompositionScope.TryGetExport(serviceType, null, out result);
            return result;
        }

        public IEnumerable&amp;lt;object&amp;gt; GetServices(Type serviceType)
        {
            if (serviceType == null) throw new ArgumentNullException(&amp;quot;serviceType&amp;quot;);

            return CompositionScope.GetExports(serviceType, null);
        }
    }
&lt;/pre&gt;&lt;br /&gt;
&lt;h2&gt;IDependencyResolver&lt;/h2&gt;
&lt;span class="codeInline"&gt;IDependencyResolver&lt;/span&gt; serves two purposes:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;It is used by WebAPI to create an &lt;span class="codeInline"&gt;IDependencyScope&lt;/span&gt; for each incoming API call&lt;/li&gt;
&lt;li&gt;It is itself an &lt;span class="codeInline"&gt;IDependencyScope&lt;/span&gt; used by Web API to access services that are required for the duration of the application’s lifetime&lt;/li&gt;&lt;/ul&gt;
&lt;br /&gt;First, to provide the required dependency scope behavior, the dependency resolver derives from the dependency scope type:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;    public class StandaloneDependencyResolver : StandaloneDependencyScope, IDependencyResolver
    {
&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The dependency resolver is initialized using a &lt;span class="codeInline"&gt;CompositionHost&lt;/span&gt; object; this is wrapped in an &lt;span class="codeInline"&gt;Export&amp;lt;CompositionContext&amp;gt;&lt;/span&gt; so that it can satisfy the base class constructor requirements:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;        readonly ExportFactory&amp;lt;CompositionContext&amp;gt; _requestScopeFactory;

        public StandaloneDependencyResolver(CompositionHost rootCompositionScope)
            : base(new Export&amp;lt;CompositionContext&amp;gt;(rootCompositionScope, rootCompositionScope.Dispose))
        {
            if (rootCompositionScope == null) throw new ArgumentNullException();
            var factoryContract = new CompositionContract(typeof(ExportFactory&amp;lt;CompositionContext&amp;gt;), null, new Dictionary&amp;lt;string, object&amp;gt; {
                { &amp;quot;SharingBoundaryNames&amp;quot;, new[] { &amp;quot;HttpRequest&amp;quot; } }
            });

            _requestScopeFactory = (ExportFactory&amp;lt;CompositionContext&amp;gt;)rootCompositionScope.GetExport(factoryContract);
        }

        public IDependencyScope BeginScope()
        {
            return new StandaloneDependencyScope(_requestScopeFactory.CreateExport());
        }
    }
&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The dependency resolver creates new dependency scopes whenever the &lt;span class="codeInline"&gt;BeginScope()&lt;/span&gt; method is called. By setting up the &lt;span class="codeInline"&gt;_requestScopeFactory&lt;/span&gt; as a sharing boundary, parts can be shared within the scope of an API call. An example of a shared part is shown below:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;        [Shared(&amp;quot;HttpRequest&amp;quot;)]
        public class EFRepository : IRepository { }
&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Parts like the &lt;span class="codeInline"&gt;EFRepository&lt;/span&gt; class are placed in a &lt;i&gt;/Parts&lt;/i&gt; folder and namespace by convention – see below.&lt;br /&gt;&lt;br /&gt;It is recommended that string constants (rather than literals like “HttpRequest” as the example shows) are used for sharing boundary names.&lt;br /&gt;
&lt;h2&gt;Initialization&lt;/h2&gt;
The dependency resolver needs to be registered with Web API when the application starts up. Here, we create a convention for parts, so that any classes in the &lt;i&gt;/Parts&lt;/i&gt; namespace within the application assembly will be used as parts for composition, in addition to API controllers:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;    private static void InitializeDependencyResolver(Assembly[] appAssemblies)
    {
        var conventions = new ConventionBuilder();

        conventions.ForTypesDerivedFrom&amp;lt;IHttpController&amp;gt;()
            .Export();

        conventions.ForTypesMatching(t =&amp;gt; t.Namespace != null &amp;amp;&amp;amp;
                  (t.Namespace.EndsWith(&amp;quot;.Parts&amp;quot;) || t.Namespace.Contains(&amp;quot;.Parts.&amp;quot;)))
            .Export()
            .ExportInterfaces();

        var container = new ContainerConfiguration()
            .WithAssemblies(appAssemblies, conventions)
            .CreateContainer();

        System.Web.Http.GlobalConfiguration.Configuration.DependencyResolver = new StandaloneDependencyResolver(container);
    }
&lt;/pre&gt;&lt;br /&gt;
&lt;h2&gt;Usage&lt;/h2&gt;
Once the dependency resolver has been initialized, API controllers can accept constructor dependencies, for example the &lt;span class="codeInline"&gt;IRepository&lt;/span&gt; interface provided by the &lt;span class="codeInline"&gt;EFRepository&lt;/span&gt;:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;    // Constructor on a controller class
    public ContactsController(IRepository repository) { }
&lt;/pre&gt;&lt;/div&gt;&lt;div class="ClearBoth"&gt;&lt;/div&gt;</description><author>alokshriram</author><pubDate>Thu, 18 Oct 2012 18:24:05 GMT</pubDate><guid isPermaLink="false">Updated Wiki: Standalone Web API dependency resolver using Microsoft.Composition 20121018062405P</guid></item><item><title>Updated Wiki: Documentation</title><link>http://mef.codeplex.com/documentation?version=17</link><description>&lt;div class="wikidoc"&gt;&lt;h2&gt;Microsoft.Composition&lt;/h2&gt;
Documentation for MEF in web and .NET for Windows Store apps on this site:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;&lt;a href="http://mef.codeplex.com/wikipage?title=What%20is%20Microsoft.Composition%3f&amp;referringTitle=Documentation"&gt;What is Microsoft.Composition&amp;#63;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://mef.codeplex.com/wikipage?title=Sharing%20and%20lifetime&amp;referringTitle=Documentation"&gt;Sharing and lifetime&lt;/a&gt; in Microsoft.Composition&lt;/li&gt;
&lt;li&gt;Extending Microsoft.Composition &lt;a href="http://mef.codeplex.com/wikipage?title=ProgrammingModelExtensions&amp;referringTitle=Documentation"&gt;with alternative programming models&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://mef.codeplex.com/wikipage?title=Avoiding%20reference%20%28memory%29%20leaks%20in%20MEF%20for%20Metro%20style%20apps&amp;referringTitle=Documentation"&gt;Avoiding reference &amp;#40;memory&amp;#41; leaks in Microsoft.Composition&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://mef.codeplex.com/wikipage?title=Unit%20Testing%20Microsoft.Composition&amp;referringTitle=Documentation"&gt;Unit Testing Microsoft.Composition&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Creating a &lt;a href="http://mef.codeplex.com/wikipage?title=Standalone%20Web%20API%20dependency%20resolver%20using%20Microsoft.Composition&amp;referringTitle=Documentation"&gt;Standalone Web API dependency resolver using Microsoft.Composition&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;To move code from MEF in the .NET Framework from 4.0 see the &lt;a href="http://mef.codeplex.com/wikipage?title=MetroChanges&amp;referringTitle=Documentation"&gt;migration guide&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://mef.codeplex.com/wikipage?title=Microsoft.Composition%20FAQ&amp;referringTitle=Documentation"&gt;Microsoft.Composition FAQ&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;

&lt;h2&gt;MEF in the .NET Framework (from 4.0)&lt;/h2&gt;
Please see the &lt;a href="http://msdn.microsoft.com/en-us/library/dd460648.aspx"&gt;introductory&lt;/a&gt; and &lt;a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.composition(VS.100).aspx"&gt;reference documentation on MSDN&lt;/a&gt; (&lt;a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.composition.hosting(VS.100).aspx"&gt;more&lt;/a&gt;).&lt;/div&gt;&lt;div class="ClearBoth"&gt;&lt;/div&gt;</description><author>alokshriram</author><pubDate>Thu, 18 Oct 2012 18:23:41 GMT</pubDate><guid isPermaLink="false">Updated Wiki: Documentation 20121018062341P</guid></item><item><title>Updated Wiki: MetroChanges</title><link>http://mef.codeplex.com/wikipage?title=MetroChanges&amp;version=2</link><description>&lt;div class="wikidoc"&gt;&lt;h1&gt;MEF for Windows 8 Windows Store apps&lt;/h1&gt;
In .NET 4.5 Beta, Windows 8 Windows Store apps could use a subset of MEF functionality from the full .NET Framework. To better align with the goals and scenarios of Windows Store apps, in .NET 4.5 RC MEF for Windows Store apps is consumed by installing the &lt;i&gt;Microsoft.Composition&lt;/i&gt; package.&lt;br /&gt;&lt;br /&gt;The MEF implementation in &lt;i&gt;Microsoft.Composition&lt;/i&gt; is not code-compatible with the MEF functionality in .NET 4.5 Beta.&lt;br /&gt;&lt;br /&gt;For most applications, a few simple steps will be required to move to the new MEF version. These are outlined step-by-step below. A full list of changes follows.&lt;br /&gt;
&lt;h1&gt;Project-level changes&lt;/h1&gt;
&lt;h2&gt;Referencing the new assemblies&lt;/h2&gt;
The new assemblies are referenced using the Visual Studio Package Manager dialog.&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Right-click on your Windows Store application project&lt;/li&gt;
&lt;li&gt;Select “Manage NuGet Packages”&lt;/li&gt;
&lt;li&gt;Select “Include Prerelease Packages”&lt;/li&gt;
&lt;li&gt;Search for Microsoft.Composition&lt;/li&gt;
&lt;li&gt;Click “Install”&lt;/li&gt;&lt;/ol&gt;
&lt;br /&gt;Alternatively, the Package Manager Console can be used:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;
Install-Package Microsoft.Composition –Pre&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Delivering MEF as a NuGet package enables a more responsive development process.&lt;br /&gt;
&lt;h2&gt;Namespace change&lt;/h2&gt;
Use Visuals Studio’s Find and Replace in Files dialog to replace the text:&lt;br /&gt;&lt;br /&gt;&lt;span class="codeInline"&gt;System.ComponentModel.Composition&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;with:&lt;br /&gt;&lt;br /&gt;&lt;span class="codeInline"&gt;System.Composition&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;b&gt;Rationale:&lt;/b&gt; MEF for Windows Store apps is optimized for this model and therefore makes changes to some fundamental MEF types like &lt;span class="codeInline"&gt;[Import]&lt;/span&gt; and &lt;span class="codeInline"&gt;[Export]&lt;/span&gt;. Changing the namespace ensures that types can be uniquely identified and correct information can be found more easily.&lt;/i&gt;&lt;br /&gt;
&lt;h1&gt;Part-level changes&lt;/h1&gt;
&lt;h2&gt;Import/Export visibility&lt;/h2&gt;
Imported and exported members must be publicly visible in order for them to be composed. For example:&lt;br /&gt;&lt;br /&gt;&lt;div style="color:Black;background-color:White;"&gt;&lt;pre&gt;
    [Import]
    &lt;span style="color:Blue;"&gt;private&lt;/span&gt; ILogger Logger { &lt;span style="color:Blue;"&gt;get&lt;/span&gt;; &lt;span style="color:Blue;"&gt;set&lt;/span&gt;; }
&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;Must be updated to:&lt;br /&gt;&lt;br /&gt;&lt;div style="color:Black;background-color:White;"&gt;&lt;pre&gt;
    [Import]
    &lt;span style="color:Blue;"&gt;public&lt;/span&gt; ILogger Logger { &lt;span style="color:Blue;"&gt;get&lt;/span&gt;; &lt;span style="color:Blue;"&gt;set&lt;/span&gt;; }
&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;The same is true of importing constructors and property exports.&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;b&gt;Rationale:&lt;/b&gt; Requiring that imports and exports are public ensures that parts behave consistently on all platforms, and that code generation techniques can be used to improve throughput.&lt;/i&gt;&lt;br /&gt;
&lt;h3&gt;Unsupported features&lt;/h3&gt;
Field exports and imports are not supported – use property imports and exports instead.&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;b&gt;Rationale:&lt;/b&gt; Due to the requirement for public imports and exports, fields are less useful for this purpose. Ignoring them improves startup time for the composition engine.&lt;/i&gt;&lt;br /&gt;
&lt;h2&gt;Part creation policy&lt;/h2&gt;
&lt;span class="codeInline"&gt;[PartCreationPolicy(CreationPolicy.NonShared)]&lt;/span&gt; is no longer required, as parts are non-shared by default.&lt;br /&gt;&lt;br /&gt;Parts that need to be shared are marked with the &lt;span class="codeInline"&gt;[Shared]&lt;/span&gt; attribute.&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;b&gt;Rationale:&lt;/b&gt; The default creation policy was previously &lt;span class="codeInline"&gt;CreationPolicy.Any&lt;/span&gt;, making it confusing to determine the scope in which a part could be used. Sharing and lifetime have been streamlined so that the sharing scope of a part is always explicitly visible – a part marked &lt;span class="codeInline"&gt;[Shared]&lt;/span&gt; will always be globally shared; a part marked &lt;span class="codeInline"&gt;[Shared(&amp;quot;vm&amp;quot;)]&lt;/span&gt; will always be shared within the named boundary “vm”, parts without an annotation are always non-shared. See also: &lt;span class="codeInline"&gt;[SharingBoundary]&lt;/span&gt; and &lt;span class="codeInline"&gt;ExportFactory&amp;lt;T&amp;gt;&lt;/span&gt;.&lt;/i&gt;&lt;br /&gt;
&lt;h2&gt;IPartImportsSatisfiedNotification&lt;/h2&gt;
This interface has been replaced with the &lt;a href="http://mef.codeplex.com/wikipage?title=OnImportsSatisfied&amp;referringTitle=MetroChanges"&gt;OnImportsSatisfied&lt;/a&gt; attribute.&lt;br /&gt;&lt;br /&gt;For example, the following part:&lt;br /&gt;&lt;br /&gt;&lt;div style="color:Black;background-color:White;"&gt;&lt;pre&gt;
    [Export]
    &lt;span style="color:Blue;"&gt;public&lt;/span&gt; &lt;span style="color:Blue;"&gt;class&lt;/span&gt; APart : IPartImportsSatisfiedNotification
    {
        &lt;span style="color:Blue;"&gt;public&lt;/span&gt; &lt;span style="color:Blue;"&gt;void&lt;/span&gt; OnImportsSatisfied() { }
    }
&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;Can be rewritten as:&lt;br /&gt;&lt;br /&gt;&lt;div style="color:Black;background-color:White;"&gt;&lt;pre&gt;
    [Export]
    &lt;span style="color:Blue;"&gt;public&lt;/span&gt; &lt;span style="color:Blue;"&gt;class&lt;/span&gt; APart 
    {
        [OnImportsSatisfied]
        &lt;span style="color:Blue;"&gt;public&lt;/span&gt; &lt;span style="color:Blue;"&gt;void&lt;/span&gt; OnImportsSatisfied() { }
    }
&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;i&gt;&lt;b&gt;Rationale:&lt;/b&gt; MEF’s convention support is based on attributes. By marking the OnImportsSatisfied() method with an attribute, conventions can select this method. This was not possible with the interface-based approach.&lt;/i&gt;&lt;br /&gt;
&lt;h2&gt;Format of Metadata Views&lt;/h2&gt;
Metadata views must be concrete types rather than interfaces. For example, the metadata view:&lt;br /&gt;&lt;br /&gt;&lt;div style="color:Black;background-color:White;"&gt;&lt;pre&gt;
    &lt;span style="color:Blue;"&gt;public&lt;/span&gt; &lt;span style="color:Blue;"&gt;interface&lt;/span&gt; INamed
    {
        &lt;span style="color:Blue;"&gt;string&lt;/span&gt; Name { &lt;span style="color:Blue;"&gt;get&lt;/span&gt;; &lt;span style="color:Blue;"&gt;set&lt;/span&gt;; }
    }
&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;Can be rewritten as:&lt;br /&gt;&lt;br /&gt;&lt;div style="color:Black;background-color:White;"&gt;&lt;pre&gt;
    &lt;span style="color:Blue;"&gt;public&lt;/span&gt; &lt;span style="color:Blue;"&gt;class&lt;/span&gt; Named
    {
        &lt;span style="color:Blue;"&gt;public&lt;/span&gt; &lt;span style="color:Blue;"&gt;string&lt;/span&gt; Name { &lt;span style="color:Blue;"&gt;get&lt;/span&gt;; &lt;span style="color:Blue;"&gt;set&lt;/span&gt;; }
    }
&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;i&gt;&lt;b&gt;Rationale:&lt;/b&gt; This requirement arises from the absence of the System.Reflection.Emit namespace in .NET for Windows Store apps. Without the functionality in this namespace, metadata views based on interfaces cannot be generated.&lt;/i&gt;&lt;br /&gt;
&lt;h1&gt;Hosting changes&lt;/h1&gt;
&lt;h2&gt;Container configuration&lt;/h2&gt;
On the hosting side, a smaller API with fewer configuration points is presented. Assemblies and part types are added to a ContainerConfiguration (rather than a catalog) and from there a container can be created and exports requested.&lt;br /&gt;&lt;br /&gt;&lt;div style="color:Black;background-color:White;"&gt;&lt;pre&gt;
    &lt;span style="color:Blue;"&gt;var&lt;/span&gt; configuration = &lt;span style="color:Blue;"&gt;new&lt;/span&gt; ContainerConfiguration()
                        .WithAssembly(&lt;span style="color:Blue;"&gt;typeof&lt;/span&gt;(App).GetTypeInfo().Assembly);

    &lt;span style="color:Blue;"&gt;using&lt;/span&gt; (&lt;span style="color:Blue;"&gt;var&lt;/span&gt; container = configuration.CreateContainer())
    {
        &lt;span style="color:Blue;"&gt;var&lt;/span&gt; handler = container.GetExport&amp;lt;IMessageHandler&amp;gt;();
        handler.Handle(message);
    }
&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;The &lt;span class="codeInline"&gt;ContainerConfiguration&lt;/span&gt; class provides a method-chaining API to add types and assemblies to the container. There is no catalog concept, nor composition batches, nor any “container hierarchy” or composition scoping APIs.&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;b&gt;Rationale:&lt;/b&gt; The hosting APIs used in MEF in the full .NET Framework are designed to support open, extensible applications. This functionality is not required in Windows Store apps, and so the developer experience is simplified.&lt;/i&gt;&lt;br /&gt;
&lt;h2&gt;Conventions and RegistrationBuilder&lt;/h2&gt;
In .NET 4.5 MEF introduces the &lt;span class="codeInline"&gt;RegistrationBuilder&lt;/span&gt; class. On Windows Store apps the same functionality is available via &lt;span class="codeInline"&gt;ConventionBuilder&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;b&gt;Rationale:&lt;/b&gt; ConventionBuilder is expected to evolve significantly in conjunction with the MEF implementation for Windows Store apps. Retaining the &lt;span class="codeInline"&gt;RegistrationBuilder&lt;/span&gt; name would make these differences confusing.&lt;/i&gt;&lt;br /&gt;
&lt;h1&gt;MEF in Windows Store apps vs. .NET Framework&lt;/h1&gt;
The table below summarizes high-level feature compatibility across MEF for Windows Store apps and the full framework.&lt;br /&gt;&lt;br /&gt;&lt;table&gt;&lt;tr&gt;&lt;th&gt;Functionality&lt;/th&gt;&lt;th&gt;Windows Store apps&lt;/th&gt;&lt;th&gt;Full&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Catalogs&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Recomposition&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Rejection&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Instance Exports&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Static Exports&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Property Exports&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Field Exports&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Importing Constructors&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Property Imports&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Field Imports&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Method Exports&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Internal Part Types&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Non Public Imports/Exports&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Export Metadata&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Import Metadata Views&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Part Metadata&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Nested Containers&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Composition Scope Definition&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Lazy Imports&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;ExportFactory Imports&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Import Many&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Import Custom Collections&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Contract Names&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Import Sources&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Cyclic Dependencies&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Open Generics&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;IPartImportsSatisfiedNotification&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Import Required Creation Policy&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Interface Metadata Views&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Concrete Metadata View s&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Missing Metadata Ignored&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Inherited Exports&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;PartCreationPolicyAttribute&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;CatalogReflectionContextAttribute&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;MetadataAttributeAttribute&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;PartNotDiscoverableAttribute&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;ICompositionService&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;CompositionOptions&lt;/td&gt;&lt;td&gt;No&lt;/td&gt;&lt;td&gt;Yes&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class="ClearBoth"&gt;&lt;/div&gt;</description><author>alokshriram</author><pubDate>Thu, 18 Oct 2012 18:22:20 GMT</pubDate><guid isPermaLink="false">Updated Wiki: MetroChanges 20121018062220P</guid></item><item><title>Updated Wiki: Avoiding reference (memory) leaks in MEF for Metro style apps</title><link>http://mef.codeplex.com/wikipage?title=Avoiding reference (memory) leaks in MEF for Metro style apps&amp;version=3</link><description>&lt;div class="wikidoc"&gt;All versions of MEF implement some level of tracking of the parts that the composition engine creates. In MEF for Windows Store apps (&lt;i&gt;System.Composition&lt;/i&gt; namespaces) this is for the purpose of ensuring that disposable parts can be released properly.&lt;br /&gt;&lt;br /&gt;To avoid holding on to part instances for longer than is required, the following guidance applies.&lt;br /&gt;&lt;br /&gt;Where multiple instances of a part need to be created, use an &lt;i&gt;ExportFactory&amp;lt;T&amp;gt;&lt;/i&gt; rather than calling &lt;i&gt;GetExports()&lt;/i&gt; multiple times on the container.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;This code may leak memory.&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;
// Within the class declaration of a part
CompositionContext _container = ...;


// If page objects have disposable dependencies,
// they will be tracked by _container.
public Page CreatePage()
{
    _container.GetExport&amp;lt;Page&amp;gt;();
}
&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;Creating a page: this code does not leak.&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;
// Within the class declaration of a part

[Import]
public ExportFactory&amp;lt;Page&amp;gt; PageFactory { get; set; }

public Page CreatePage()
{
   return PageFactory.CreateExport().Value;
}
&lt;/pre&gt;&lt;br /&gt;If the &lt;i&gt;Export&amp;lt;T&amp;gt;&lt;/i&gt; instance is garbage collected, all collectible parts will also be free for collection (regardless of whether or not &lt;i&gt;Dispose()&lt;/i&gt; is called).&lt;br /&gt;&lt;br /&gt;The &lt;i&gt;Export&amp;lt;T&amp;gt;&lt;/i&gt; instance returned from the &lt;i&gt;CreateExport()&lt;/i&gt; method can be disposed in order to dispose related parts:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;
public void ShowPage()
{
   using (var page = PageFactory.CreateExport())
   {
      // Outside the using block, the page and its dependencies
      // will be disposed.
      page.Value.Show();
   }
}
&lt;/pre&gt;&lt;br /&gt;If you need to use &lt;i&gt;CompositionContext&lt;/i&gt; (rather than &lt;i&gt;ExportFactory&amp;lt;T&amp;gt;&lt;/i&gt;) for some reason, e.g. to implement a service locator, then use &lt;i&gt;ExportFactory&amp;lt;CompositionContext&amp;gt;&lt;/i&gt; to create a new &lt;i&gt;CompositionContext&lt;/i&gt; for each unit of work.&lt;br /&gt;&lt;br /&gt;This applies when using &lt;i&gt;CompositionContext.SatisfyImports()&lt;/i&gt; as well.&lt;br /&gt;&lt;/div&gt;&lt;div class="ClearBoth"&gt;&lt;/div&gt;</description><author>alokshriram</author><pubDate>Thu, 18 Oct 2012 18:19:12 GMT</pubDate><guid isPermaLink="false">Updated Wiki: Avoiding reference (memory) leaks in MEF for Metro style apps 20121018061912P</guid></item><item><title>Updated Wiki: ProgrammingModelExtensions</title><link>http://mef.codeplex.com/wikipage?title=ProgrammingModelExtensions&amp;version=6</link><description>&lt;div class="wikidoc"&gt;&lt;h2&gt;Extending Microsoft.Composition with Alternative Programming Models&lt;/h2&gt;
MEF for web and Windows Store apps (aka the Microsoft.Composition NuGet package) set out with the design goal to ship a lean core composition engine that can be richly extended. Most IoC containers follow this philosophy, so to be a bit more specific about our goals:&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Most simple extensions should be simple to write and explain &lt;/li&gt;
&lt;li&gt;Extensions should provide the same performance, robustness and diagnostics as the core features&lt;/li&gt;
&lt;li&gt;A few broad extension points are preferable to many narrow ones&lt;/li&gt;&lt;/ol&gt;
&lt;br /&gt;To keep complexity at a minimum it was also our intention to implement as many container features as possible as ‘extensions’, even if they ship in the core package.&lt;br /&gt;&lt;br /&gt;In this page we’ll walk through one simple scenario, examine the container extension points that support it, and discuss a few other ways in which these extension points can be put to use.&lt;br /&gt;
&lt;h2&gt;What is a Programming Model?&lt;/h2&gt;
The programming model determines how parts are described for the container. Out of the box, Microsoft.Composition supports the familiar MEF Attributed Programming Model in which parts are regular .NET classes marked up with Import and Export attributes.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;
[Export(typeof(IAmusement))]
public class Rollercoaster : IAmusement
{
    [Import]
    public ITrack Track { get; set; }
}
&lt;/pre&gt;&lt;br /&gt;The Attributed Programming Model is quite flexible and provides support for custom attribute types and for rule-based conventions, but all of these build on the basic programming model foundation for using exports from class-based parts. There are many other ways that values can be supplied for composition.&lt;br /&gt;
&lt;h2&gt;Using Web.config Settings as Exports&lt;/h2&gt;
Let’s consider parts that need to be configured with settings from an App.config or Web.config file. Here we’ve created a custom Setting attribute that specifies the key for the setting:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;
[Export]
public class Downloader
{
    readonly string _url;

    [ImportingConstructor]
    public Downloader([Setting(&amp;quot;serverUrl&amp;quot;)] string url)
    {
        _url = url;
    }

    public void Download()
    {
        Console.WriteLine(&amp;quot;Downloading from {0}...&amp;quot;, _url);
    }
}
&lt;/pre&gt;&lt;br /&gt;This hypothetical part, in addition to whatever other imports it has, needs to be configured with the URL of a server. Our container extension is going to enable the serverUrl parameter to be read from the application configuration file:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
&amp;lt;configuration&amp;gt;
  &amp;lt;appSettings&amp;gt;
    &amp;lt;add key=&amp;quot;serverUrl&amp;quot; value=&amp;quot;http://mef.codeplex.com&amp;quot; /&amp;gt;
  &amp;lt;/appSettings&amp;gt;
&amp;lt;/configuration&amp;gt;
&lt;/pre&gt;&lt;br /&gt;This effectively turns XML app configuration into a programming model for the container; once it is enabled, appSettings entries specify exports that other parts can consume.&lt;br /&gt;&lt;br /&gt;Some might suggest that this is too much coupling between the importing part and the configuration file; this is a reasonable viewpoint, but the model does have some benefits, for example settings used by an application are declaratively discoverable. Like everything, the technique has pros and cons; as an example it covers a lot of the container extension API so let’s run with it here.&lt;br /&gt;
&lt;h2&gt;Composition Contracts&lt;/h2&gt;
Microsoft.Composition matches exports to imports based on contracts. A contract is a familiar MEF construct:&lt;br /&gt;&lt;br /&gt;&lt;img src="http://i3.codeplex.com/Download?ProjectName=MEF&amp;DownloadId=392799" alt="Contract.png" title="Contract.png" /&gt;&lt;br /&gt; &lt;br /&gt;In order for an import to match an export, they must share the same contract type, have the same contract name (if any) and have compatible metadata constraints. We write out contracts in the following format:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;
ContractType &amp;quot;contractName&amp;quot; { ConstraintName = value, ...}
&lt;/pre&gt;&lt;br /&gt;Whenever the container encounters an import for a new contract, it queries the available extensions to see if they can supply a matching export. We’re going to take advantage of this feature to supply a value whenever a part imports an app setting. The first step of that is to determine what the contract for a Setting import will look like.&lt;br /&gt;
&lt;h2&gt;Constraining the Imported Contract&lt;/h2&gt;
If we return to the constructor of the Downloader part, without our custom Setting attribute, it looks like this:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;
    [ImportingConstructor]
    public Downloader(string url)
&lt;/pre&gt;&lt;br /&gt;This makes url into a vanilla MEF import, with a contract that looks simply like:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;
System.String
&lt;/pre&gt;&lt;br /&gt;This isn’t a great contract – it is so broad that any string will match, there’s no way to match this up with a specific setting value.&lt;br /&gt;&lt;br /&gt;We want to ensure that settings are only supplied a very specific value, and the mechanism for doing that is Metadata Constraints. Each constraint comprises a name and a value:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;
System.String { SettingKey = &amp;quot;serverUrl&amp;quot; }
&lt;/pre&gt;&lt;br /&gt;The rules of contracts require that constraints match exactly, so this contract will no longer be satisfied by just any old string: perfect for our purposes. To specify a metadata constraint on an import, we can use the standard ImportMetadataConstraint attribute:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;
    [ImportingConstructor]
    public Downloader([ImportMetadataConstraint(&amp;quot;SettingKey&amp;quot;, &amp;quot;serverUrl&amp;quot;)] string url)
&lt;/pre&gt;&lt;br /&gt;This works but is a bit verbose to use frequently. MEF allows the creation of custom attributes to specify export metadata, and the same attributes can be applied to imports to specify metadata constraints. The Setting attribute is such an attribute:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Parameter)]
[MetadataAttribute]
public class SettingAttribute : Attribute
{
    readonly string _key;

    public SettingAttribute(string key)
    {
        _key = key;
    }

    public string SettingKey { get { return _key; } }
}
&lt;/pre&gt;&lt;br /&gt;We can now use our desired syntax to import settings:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;
    [ImportingConstructor]
    public Downloader([Setting(&amp;quot;serverUrl&amp;quot;)] string url)
&lt;/pre&gt;&lt;br /&gt;Using the Setting attribute on an appropriate export will match the import: &lt;br /&gt;&lt;br /&gt;&lt;pre&gt;
    [Export, Setting(&amp;quot;serverUrl&amp;quot;)]
    public string Url { get { return ... } }
&lt;/pre&gt;&lt;br /&gt;That isn’t our goal here however. The other side of our extension is going to match these constraints and supply exports from the configuration file.&lt;br /&gt;
&lt;h2&gt;Plugging in an ExportDescriptorProvider&lt;/h2&gt;
We can plug support for settings into the container as an ExportDescriptorProvider when the container is configured:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;
var configuration = new ContainerConfiguration()
    .WithAssembly(typeof(Program).Assembly)
    .WithProvider(new AppSettingsExportDescriptorProvider());
&lt;/pre&gt;&lt;br /&gt;The AppSettingsExportDescriptorProvider will be queried whenever the container encounters a new contract. If the contract has a SettingKey constraint, and the value exists in the App.config file, then the provider will return an ExportDescriptor that the container can later use to retrieve the value. We’ll show the complete listing for the provider, then break down each of the steps involved:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;
public class AppSettingsExportDescriptorProvider : ExportDescriptorProvider
{
    static readonly Type[] SupportedSettingTypes = new[] { typeof(string), typeof(int), typeof(double), typeof(DateTime), typeof(TimeSpan) };


    public override IEnumerable&amp;lt;ExportDescriptorPromise&amp;gt; GetExportDescriptors(
        CompositionContract contract, DependencyAccessor dependencyAccessor)
    {
        string key;
        CompositionContract unwrapped;

        if (!contract.TryUnwrapMetadataConstraint(&amp;quot;SettingKey&amp;quot;, out key, out unwrapped))
            return NoExportDescriptors;

        if (!unwrapped.Equals(new CompositionContract(unwrapped.ContractType)))
            return NoExportDescriptors;

        if (!SupportedSettingTypes.Contains(unwrapped.ContractType))
            return NoExportDescriptors;

        var value = ConfigurationManager.AppSettings.Get(key);
        if (value == null)
            return NoExportDescriptors;

        var converted = Convert.ChangeType(value, contract.ContractType);

        return new[] {
            new ExportDescriptorPromise(
                contract,
                &amp;quot;Application Configuration&amp;quot;,
                true,
                NoDependencies,
                _ =&amp;gt; ExportDescriptor.Create((c, o) =&amp;gt; converted, NoMetadata)) };
    }
}
&lt;/pre&gt;&lt;br /&gt;The provider implements one method, GetExportDescriptors(), that takes a CompositionContract and returns a list of ExportDescriptorPromises. The DependencyAccessor parameter isn’t used in this example.&lt;br /&gt;&lt;br /&gt;The first step in implementing the provider is determining whether the contract has a SettingKey constraint applied. If not, then the request isn’t for an app setting, so the provider returns an empty list:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;
        string key;
        CompositionContract unwrapped;

        if (!contract.TryUnwrapMetadataConstraint(&amp;quot;SettingKey&amp;quot;, out key, out unwrapped))
            return NoExportDescriptors;
&lt;/pre&gt;&lt;br /&gt;If the check succeeds, then key will hold the setting key, for example “serverUrl”, and unwrapped will contain the remainder of the contract with the constraint removed. So, in the downloader example, the contract is:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;
System.String { SettingKey = &amp;quot;serverUrl&amp;quot; }
&lt;/pre&gt;&lt;br /&gt;This will be unwrapped into:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;
System.String
&lt;/pre&gt;&lt;br /&gt;The next check in the provider makes sure that no name or additional constraints are applied to the contract:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;
        if (!unwrapped.Equals(new CompositionContract(unwrapped.ContractType)))
            return NoExportDescriptors;
&lt;/pre&gt;&lt;br /&gt;If there are additional constraints that this provider does not understand, or if there’s a contract name applied, then we return nothing. It is very important that providers only match contracts that they understand completely.&lt;br /&gt;&lt;br /&gt;For the same reason, the provider checks that the type is a supported setting type. Doing so ensures that the code will properly support Lazy&amp;lt;T&amp;gt; and other relationship types for settings:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;
        if (!SupportedSettingTypes.Contains(unwrapped.ContractType))
            return NoExportDescriptors;
&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The next step checks to see if there is a matching value in the application configuration store. If not, perhaps the contract will be supplied another way, so the provider returns an empty list:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;
        var value = ConfigurationManager.AppSettings.Get(key);
        if (value == null)
            return NoExportDescriptors;
&lt;/pre&gt;&lt;br /&gt;Now that we’re sure the contract is for an app setting, and the key exists in the configuration file, we change the type of the value to match the requested contract type.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;
        var converted = Convert.ChangeType(value, contract.ContractType);
&lt;/pre&gt;&lt;br /&gt;In this implementation we simply throw an exception if the conversion fails, a better implementation would test for assignability and return an empty list if the types could not be matched.&lt;br /&gt;&lt;br /&gt;Now that we have a setting value to match the requested contract, the final step provides the composition engine with all the information it needs to:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Validate the dependency graph&lt;/li&gt;
&lt;li&gt;Supply good error messages to the user if necessary&lt;/li&gt;
&lt;li&gt;Quickly access the exported value during composition&lt;/li&gt;&lt;/ul&gt;
&lt;br /&gt;This information is all wrapped up in the ExportDescriptorPromise that we return:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;
        return new[] {
            new ExportDescriptorPromise(
                contract,
                &amp;quot;Application Configuration&amp;quot;,
                true,
                NoDependencies,
                _ =&amp;gt; ExportDescriptor.Create((c, o) =&amp;gt; converted, NoMetadata)) };
&lt;/pre&gt;&lt;br /&gt;The “Application Configuration” string describes where the value came from, in case it is needed in an error message. An example could be the case where the same setting is provided elsewhere in the composition:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;
Only one export for the contract &amp;#39;String { SettingKey = &amp;quot;serverUrl&amp;quot; }&amp;#39; is allowed, but the following parts: &amp;#39;Application Configuration&amp;#39;, &amp;#39;SomeOtherPart&amp;#39; export it.
 -&amp;gt; required by import &amp;#39;serverUrl&amp;#39; of part &amp;#39;Downloader&amp;#39;
&lt;/pre&gt;&lt;br /&gt;The other more mysterious parameter here is simply ‘true’. This indicates to the composition engine that the resulting instance is shared, and in conjunction with the dependency information returned can be used to check for dependency cycles and so on.&lt;br /&gt;
&lt;h2&gt;What else is Possible?&lt;/h2&gt;There are a number of sample extensions in the MEF CodePlex source repository built using plugged-in ExportDescriptorProviders. These can be found in the /oob/demo subfolder.&lt;br /&gt;&lt;br /&gt;&lt;table&gt;&lt;tr&gt;&lt;th&gt; Extension &lt;/th&gt;&lt;th&gt; Description &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; App Settings &lt;/td&gt;&lt;td&gt; The topic of this post. Use &amp;lt;appSetting&amp;gt; values as exports. &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; Instances &lt;/td&gt;&lt;td&gt; Use an existing instance as an export. &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; Delegates &lt;/td&gt;&lt;td&gt; Use a supplied delegate to create exported instances on the fly. &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; Resolve any Concrete Type &lt;/td&gt;&lt;td&gt; “Automatically” supply any concrete type with a parameterless constructor as an export. &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Dictionary Imports &lt;/td&gt;&lt;td&gt; Import a dictionary keyed by an export metadata value. &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Ordered ImportMany &lt;/td&gt;&lt;td&gt; Order an imported collection using a value from metadata. &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; Default-only Exports &lt;/td&gt;&lt;td&gt; Specify that an export is a default that is used only when no other export exists for the same contract. &lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;br /&gt;&lt;br /&gt;Within the container itself, the Attributed Programming Model is plugged in this way via the TypedPartExportDescriptorProvider, and the technique is used so that the container can supply the current CompositionContext to parts as an import as well. Support for ImportMany, Lazy&amp;lt;T&amp;gt;, ExportFactory&amp;lt;T&amp;gt;, metadata view providers are all plugged in this way.&lt;br /&gt;&lt;br /&gt;It is feasible that this extension point could be used to implement an “auto-mocking” container, where the exports are generated on the fly by a mocking framework. It is also conceivable that this extension point might be used to implement a completely different type-based programming model from the attributed one supplied in the box, perhaps mimicking that of another composition framework.&lt;br /&gt;&lt;/div&gt;&lt;div class="ClearBoth"&gt;&lt;/div&gt;</description><author>alokshriram</author><pubDate>Thu, 18 Oct 2012 18:18:23 GMT</pubDate><guid isPermaLink="false">Updated Wiki: ProgrammingModelExtensions 20121018061823P</guid></item><item><title>Updated Wiki: What is Microsoft.Composition?</title><link>http://mef.codeplex.com/wikipage?title=What is Microsoft.Composition?&amp;version=5</link><description>&lt;div class="wikidoc"&gt;&lt;a href="http://nuget.org/packages/microsoft.composition"&gt;Microsoft.Composition&lt;/a&gt; is an update for MEF that is optimized for web and Windows 8 Store apps. It is distributed as a NuGet package compatible with the .NET 4.5 Framework and .NET for Windows Store apps.&lt;br /&gt;&lt;br /&gt;These environments do not emphasize in-place third party extensibility, and so composition in these environments can be simplified and streamlined.&lt;br /&gt;&lt;br /&gt;Microsoft.Composition includes a lifetime model oriented towards the &amp;#39;unit of work&amp;#39; patterns that appear in server-side and MVVM-style applications.&lt;br /&gt;&lt;br /&gt;Throughput under server workloads is several orders of magnitude higher than what can be achieved with CompositionContainer, and with almost zero contention.&lt;br /&gt;
&lt;h2&gt;Getting Started&lt;/h2&gt;
First, install the &lt;a href="http://nuget.org/packages/microsoft.composition"&gt;Microsoft.Composition NuGet package&lt;/a&gt; using the &lt;i&gt;Manage NuGet Packages&lt;/i&gt; dialog in Visual Studio, or from the &lt;i&gt;Package Manager Console&lt;/i&gt;:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;
PM&amp;gt; Install-Package Microsoft.Composition -Pre
&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;This will add a number of assemblies to the project.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Parts&lt;/b&gt; for Microsoft.Composition use the familiar MEF attributes, found in the &lt;span class="codeInline"&gt;System.Composition&lt;/span&gt; namespace.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;
[Export(typeof(IMessageHandler))]
public class MessageHandler : IMessageHandler
{
    [ImportingConstructor]
    public MessageHandler(IDatabaseConnection connection)
    {
    }
}
&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The &lt;b&gt;container&lt;/b&gt; is created using a simple &lt;span class="codeInline"&gt;ContainerConfiguration&lt;/span&gt; class.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;
var configuration = new ContainerConfiguration()
    .WithAssembly(typeof(MessageHandler).Assembly);

using (var container = configuration.CreateContainer())
{
    var greeter = container.GetExport&amp;lt;IMessageHandler&amp;gt;();
    greeter.Greet();
}
&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="codeInline"&gt;ContainerConfiguration&lt;/span&gt; provides the methods &lt;span class="codeInline"&gt;WithPart()&lt;/span&gt; and &lt;span class="codeInline"&gt;WithAssembly()&lt;/span&gt; as well as the &lt;span class="codeInline"&gt;WithProvider()&lt;/span&gt; method for plugging in container extensions.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Conventions&lt;/b&gt; are defined in Microsoft.Composition using &lt;span class="codeInline"&gt;ConventionBuilder&lt;/span&gt;:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;
var conventions = new ConventionBuilder();
conventions.ForTypesDerivedFrom&amp;lt;IMessageHandler&amp;gt;().Export();
&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The &lt;span class="codeInline"&gt;WithPart()&lt;/span&gt; and &lt;span class="codeInline"&gt;WithAssembly()&lt;/span&gt; configuration methods accept conventions as parameters:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;
configuration.WithPart&amp;lt;MessageHandler&amp;gt;(conventions);
&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="codeInline"&gt;ConventionBuilder&lt;/span&gt; supports the same syntax and rules as &lt;span class="codeInline"&gt;RegistrationBuilder&lt;/span&gt; does in the full-framework version of MEF. The BCL Team Blog discusses how to &lt;a href="http://blogs.msdn.com/b/bclteam/archive/2011/11/01/getting-started-with-convention-based-part-registration-in-mef-version-2.aspx"&gt;define&lt;/a&gt; and &lt;a href="http://blogs.msdn.com/b/bclteam/archive/2011/11/03/overriding-part-registration-conventions-with-the-mef-attributes-nick.aspx"&gt;override&lt;/a&gt; conventions.&lt;br /&gt;&lt;br /&gt;If you are familiar with MEF in the .NET Framework 4.0 and onwards, see the &lt;a href="http://mef.codeplex.com/wikipage?title=MetroChanges&amp;referringTitle=What%20is%20Microsoft.Composition%3f"&gt;migration guide&lt;/a&gt; for further information.&lt;/div&gt;&lt;div class="ClearBoth"&gt;&lt;/div&gt;</description><author>alokshriram</author><pubDate>Thu, 18 Oct 2012 18:17:48 GMT</pubDate><guid isPermaLink="false">Updated Wiki: What is Microsoft.Composition? 20121018061748P</guid></item><item><title>Updated Wiki: Documentation</title><link>http://mef.codeplex.com/documentation?version=16</link><description>&lt;div class="wikidoc"&gt;&lt;h2&gt;Microsoft.Composition&lt;/h2&gt;
Documentation for MEF in web and .NET for Windows Store apps on this site:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;&lt;a href="http://mef.codeplex.com/wikipage?title=What%20is%20Microsoft.Composition%3f&amp;referringTitle=Documentation"&gt;What is Microsoft.Composition&amp;#63;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://mef.codeplex.com/wikipage?title=Sharing%20and%20lifetime&amp;referringTitle=Documentation"&gt;Sharing and lifetime&lt;/a&gt; in Microsoft.Composition&lt;/li&gt;
&lt;li&gt;Extending Microsoft.Composition &lt;a href="http://mef.codeplex.com/wikipage?title=ProgrammingModelExtensions&amp;referringTitle=Documentation"&gt;with alternative programming models&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://mef.codeplex.com/wikipage?title=Avoiding%20reference%20%28memory%29%20leaks%20in%20MEF%20for%20Metro%20style%20apps&amp;referringTitle=Documentation"&gt;Avoiding reference &amp;#40;memory&amp;#41; leaks in Microsoft.Composition&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://mef.codeplex.com/wikipage?title=Unit%20Testing%20Microsoft.Composition&amp;referringTitle=Documentation"&gt;Unit Testing Microsoft.Composition&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Creating a &lt;a href="http://mef.codeplex.com/wikipage?title=Standalone%20Web%20API%20dependency%20resolver%20using%20Microsoft.Composition&amp;referringTitle=Documentation"&gt;Standalone Web API dependency resolver using Microsoft.Composition&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;To move code from MEF in the .NET Framework from 4.0 see the &lt;a href="http://mef.codeplex.com/wikipage?title=MetroChanges&amp;referringTitle=Documentation"&gt;migration guide&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://mef.codeplex.com/wikipage?title=Microsoft.Composition%20FAQ&amp;referringTitle=Documentation"&gt;Microsoft.Composition FAQ&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;

&lt;h2&gt;MEF in the .NET Framework (from 4.0)&lt;/h2&gt;
Please see the &lt;a href="http://msdn.microsoft.com/en-us/library/dd460648.aspx"&gt;introductory&lt;/a&gt; and &lt;a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.composition(VS.100).aspx"&gt;reference documentation on MSDN&lt;/a&gt; (&lt;a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.composition.hosting(VS.100).aspx"&gt;more&lt;/a&gt;).&lt;/div&gt;&lt;div class="ClearBoth"&gt;&lt;/div&gt;</description><author>alokshriram</author><pubDate>Thu, 18 Oct 2012 18:16:49 GMT</pubDate><guid isPermaLink="false">Updated Wiki: Documentation 20121018061649P</guid></item><item><title>Updated Wiki: Home</title><link>http://mef.codeplex.com/wikipage?version=91</link><description>&lt;div class="wikidoc"&gt;&lt;h2&gt;Welcome to the MEF Community Site&lt;/h2&gt;
&lt;b&gt;Important:&lt;/b&gt; this site hosts source code for &lt;u&gt;unsupported, pre-release versions&lt;/u&gt; of MEF. If you want to use MEF in production, you should strongly consider using the supported versions included in &lt;a href="http://www.microsoft.com/net"&gt;the .NET Framework&lt;/a&gt; and &lt;a href="http://silverlight.net"&gt;Silverlight&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;table&gt;&lt;tr&gt;&lt;th&gt; .NET 4.5 and Windows 8 Store apps can now install the fully-supported, lightweight &lt;a href="http://nuget.org/packages/microsoft.composition"&gt;Microsoft.Composition package&lt;/a&gt; from NuGet. &lt;/th&gt;&lt;/tr&gt;&lt;/table&gt;&lt;br /&gt;
&lt;h3&gt;What is it?&lt;/h3&gt;
The &lt;b&gt;Managed Extensibility Framework&lt;/b&gt; (MEF) is a composition layer for .NET that improves the flexibility, maintainability and testability of large applications. MEF can be used for third-party plugin extensibility, or it can bring the benefits of a loosely-coupled plugin-like architecture to regular applications.&lt;br /&gt;
&lt;h3&gt;Status&lt;/h3&gt;
MEF is a part of the Microsoft .NET Framework, with types primarily under the &lt;i&gt;System.ComponentModel.Composition.*&lt;/i&gt; namespaces.&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;MEF has shipped with .NET 4.0 and Silverlight 4&lt;/li&gt;
&lt;li&gt;MEF 2 is under development
&lt;ul&gt;&lt;li&gt;New features are available in pre-release versions of &lt;a href="http://msdn.microsoft.com/en-us/library/ms171868(v=vs.110).aspx#core"&gt;the .NET Framework 4.5&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Windows 8 Store apps are supported via &lt;a href="https://nuget.org/packages/microsoft.composition"&gt;NuGet&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;/div&gt;&lt;div class="ClearBoth"&gt;&lt;/div&gt;</description><author>alokshriram</author><pubDate>Thu, 18 Oct 2012 18:15:49 GMT</pubDate><guid isPermaLink="false">Updated Wiki: Home 20121018061549P</guid></item></channel></rss>