This is the first time I am using the Framework Managed Extensibility Framework in Visual Studio 2010 beta using System.ComponentModel.Composition from .net-4.0.
I was unable to get CompositionContainer to find my implementation assemblies using the two alternative routines below.
First attempt (this worked in an earlier version of the MEF code):
var composition = new CompositionBatch();
composition.AddPart(this);
var container = new CompositionContainer(new DirectoryCatalog(AppDomain.CurrentDomain.BaseDirectory));
container.Compose(composition);
Second attempt (I think this worked in beta 1):
var aggregateCatalog = new AggregateCatalog(
new AssemblyCatalog(Assembly.GetExecutingAssembly()),
new DirectoryCatalog(AppDomain.CurrentDomain.BaseDirectory));
var compositionContainer = new CompositionContainer(aggregateCatalog);
compositionContainer.ComposeParts(this);
Is there a new way to do this in beta 2?
EDITOR: It had nothing to do with the composition. I had a static property representing my imported implementation:
[Import] public static ILog Log { get; set; }
which was supposed to be:
[Import] public ILog Log { get; set; }
I marked Daniel’s answer as accepted because the debug sage’s advice more thoroughly solved the problem.