I play with the new System.ComponentModel.Composition namespace in .NET 4.0 beta 2, also known as the Managed Extensibility Framework .
I use the following C # example where Monkey imports Banana :
public interface IBanana { } [Export(typeof(IBanana))] public class Banana : IBanana { } public class Monkey { [Import(typeof(IBanana))] public IBanana Banana { get; set; } }
However, when I try to compose a monkey as follows, I get an InvalidOperationException message with the message " This object has not been initialized - the" SourceProvider "property must be set. ":
var exportProvider = new CatalogExportProvider(new TypeCatalog(typeof(Banana))); var container = new CompositionContainer(exportProvider); var monkey = new Monkey(); container.ComposeParts(monkey);
What am I missing here? I know that I can transfer the directory directly without wrapping it in CatelogExportProvider, but should it not work above?
source share