I am trying out the Managed Extensibility Framework for the first time in Visual Studio 2010 beta 2 using the System.ComponentModel.Composition from .net-4.0.
I have been unable to get the CompositionContainer to find my implementation assemblies using the two alternative routines below.
First attempt (this worked in an older codeplex release of MEF):
var composition = new CompositionBatch();
composition.AddPart(this);
var container = new CompositionContainer(new DirectoryCatalog(AppDomain.CurrentDomain.BaseDirectory));
container.Compose(composition);
Second attempt (this worked in beta 1, I think):
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?
EDIT: It turned out to be nothing to do with the composition. I had a static property representing my imported implementation:
[Import] public static ILog Log { get; set; }
which should have been:
[Import] public ILog Log { get; set; }
I marked Daniel's answer as accepted because the sage advice of debugging in a more thorough fashion solved the problem.