title: MEF - Migration from .NET 3.5 to .NET 4.0
body: <p>I've got an easy sample from the internet that works fine in the .NET 3.5 framework using System.ComponentModel.Composition.dll version <strong>v2.0.50727</strong></p>
  
  <p>I've changed the project definition and changed the target to .NET 4.0 and it works perfect.</p>
  
  <p>When I replace the v2.0.50727 version of the above .dll to the latest version which is <strong>v4.0.30319</strong> I get an error that complains during the composition of the container. The code where it break is as follows:</p>
  
  <pre><code>
          private void LoadPlugins() {
              var catalog = new AssemblyCatalog(Assembly.GetExecutingAssembly());
  
              var container = new CompositionContainer(catalog);
                          container.ExportsChanging += new EventHandler(container_ExportsChanging);
  
              var batch = new CompositionBatch();
              batch.AddPart(this);
              container.Compose(batch); // throws Exception
          }
  </code></pre>
  
  <p>And the exception is the following:</p>
  
  <pre><code>
  System.ComponentModel.Composition.ChangeRejectedException was unhandled
  Message=The composition remains unchanged. The changes were rejected because of the following error(s): The composition produced a single composition error. The root cause is provided below. Review the CompositionException.Errors property for more detailed information.
  
  1) More than one export was found that matches the constraint '((exportDefinition.ContractName == "MefTutorial.IPlugin") AndAlso (exportDefinition.Metadata.ContainsKey("ExportTypeIdentity") AndAlso "MefTutorial.IPlugin".Equals(exportDefinition.Metadata.get_Item("ExportTypeIdentity"))))'.
  
  Resulting in: Cannot set import 'MefTutorial.PluginConsumer._myPlugins (ContractName="MefTutorial.IPlugin")' on part 'MefTutorial.PluginConsumer'.
  Element: MefTutorial.PluginConsumer._myPlugins (ContractName="MefTutorial.IPlugin") --> MefTutorial.PluginConsumer
  </code></pre>
  
  <p>What do I need to do to migrate to the .NET 4.0 concerning <strong>MEF</strong>?</p>