Jan 21, 2012 at 9:16 PM
Edited Jan 21, 2012 at 9:17 PM
Okay, I found out that the Providers property on the Catalog property in the Bootstrapper actually had Count = 0. This proved my assumption that the ExportFactoryProvider was not registered with the Catalog.
For me it was hard to figure out how to register it correctly, but after much of reading I think I found the correct way:
protected override CompositionContainer CreateContainer()
var exportFactoryProvider = new ExportFactoryProvider();
var container = new CompositionContainer(AggregateCatalog, exportFactoryProvider);
exportFactoryProvider.SourceProvider = container;
The override of ConfigureContainer I came up with in my first post can be removed as it is not needed anymore.
Unfortunately while the catalog now contains the ExportFactoryProvider in the Providers property i receive another error while trying to use it.
When the class in which I defined the ViewModelFactory property loads I receive a NullPointerException at the following statement in the 'ExportFactoryInstantiationProvider.cs' file (part of Glenn's code) in the
protected override IEnumerable<Export> GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
if (cbid == null || !cbid.RequiredTypeIdentity.StartsWith(PartCreatorContractPrefix))
The RequiredTypIdentity is null, so the exception thrown is a NullPointerException.
Am I doing anything wrong? The unit tests glenn created run fine.