/* MEF does not allow recomposition on constructor imports, that is without a bit of help :-) The helper class Recomposable is a wrapper part that specifies a recomposable import that can be accessed through it's Value property. In order to use it, you need to manually register specific Recomposables for each type you would like to wrap. In the sample below there are 2 loggers, DefaultLogger and OverridingLoggers which both export ILogger. UsesLogger imports Recomposable in the constructor. First we add the default logger to the container and compose. Then we see that the default logger's type name. Next we replace the DefaultLogger with the OverridingLogger and recompose and we see that it's name is outputted ot the console after composition. namespace ConstructorRecomposition { public class Program { public static void Main(params string[] args) { //manually create a catalog and the container var catalog = new TypeCatalog(typeof (UsesLogger), typeof (Recomposable)); var container = new CompositionContainer(catalog); //create a batch, add the default logger and ocmpose var batch = new CompositionBatch(); var defaultLogger = new DefaultLogger(); var defaultLoggerPart = batch.AddPart(defaultLogger); container.Compose(batch); //grab the UsesLogger and output the logger that it immported var usesLogger = container.GetExportedObject(); Console.WriteLine(usesLogger.Logger); //create a new batch and replace the default logger with an overriding logger and compose batch = new CompositionBatch(); batch.RemovePart(defaultLoggerPart); batch.AddPart(new OverridingLogger()); container.Compose(batch); //output the logger Console.WriteLine(usesLogger.Logger); Console.ReadLine(); } } [Export(typeof(ILogger))] public class DefaultLogger : ILogger { public DefaultLogger() { } } [Export(typeof(ILogger))] public class OverridingLogger : ILogger { public OverridingLogger() { } } public interface ILogger { } [Export] public class UsesLogger { [ImportingConstructor] public UsesLogger(Recomposable logger) { _recompLogger = logger; } private Recomposable _recompLogger; public ILogger Logger { get { return _recompLogger.Value; } } } } */ [Export] public class Recomposable { [Import(AllowRecomposition=true)] public T Value { get; private set; } }