I am trying to move to Cocktail from DAF. I have almost everything working apart from not being able to import IEventAgregator.
1) No valid exports were found that match the constraint '((exportDefinition.ContractName == "Caliburn.Micro.IEventAggregator")
I am at a loss as to why it is not being exported.
I have included my Bootstrapper code. Hopefully someone can see what I am doing wrong and needs to be changed. It all worked in the old DAF.
public class WpfBootstrapper : FrameworkBootstrapper<IShell>
{
private CompositionContainer _container;
public WpfBootstrapper()
{
// Uncomment to enable Caliburn Micro logging
// LogManager.GetLog = (Type t) => Torpedo.Geo.Shared.Helper.CaliburnDebugLog.GetInstanceForType(t);
}
protected override void PrepareCompositionContainer(CompositionBatch batch)
{
base.PrepareCompositionContainer(batch);
// batch.AddExportedValue<IWindowManager>(new WindowManager());
_container = new CompositionContainer(new AggregateCatalog(
AssemblySource.Instance.Select(x => new AssemblyCatalog(x)).OfType<ComposablePartCatalog>()
));
batch.AddExportedValue<IEntityManagerProvider<TorpedoEntities>>(new EntityManagerProvider<TorpedoEntities>());
batch.AddExportedValue<IAuthenticationService>(new AuthenticationService());
batch.AddExportedValue<Func<IMessageBox>>(() => _container.GetExportedValue<IMessageBox>());
batch.AddExportedValue<Func<ILocationViewModel>>(() => _container.GetExportedValue<ILocationViewModel>());
batch.AddExportedValue<Func<IAssayBatchViewModel>>(() => _container.GetExportedValue<IAssayBatchViewModel>());
batch.AddExportedValue<Func<IImportToDataViewViewModel>>(() => _container.GetExportedValue<IImportToDataViewViewModel>());
batch.AddExportedValue<Func<IImportToObjectsViewModel>>(() => _container.GetExportedValue<IImportToObjectsViewModel>());
_container.Compose(batch);
}
protected override IEnumerable<Assembly> SelectAssemblies()
{
return new[] {
Assembly.GetExecutingAssembly(),
//Assembly.LoadFrom("Torpedo.Geo.WPF.Mapping.dll"),
Assembly.LoadFrom("Torpedo.Geo.WPF.Viewer.dll"),
Assembly.LoadFrom("Torpedo.Geo.WPF.LocationDetail.dll"),
Assembly.LoadFrom("Torpedo.Geo.WPF.Assay.dll"),
Assembly.LoadFrom("Torpedo.Geo.WPF.Admin.dll"),
Assembly.LoadFrom("Torpedo.Geo.WPF.Import.dll"),
Assembly.LoadFrom("Torpedo.Geo.Shared.dll")
};
}
protected override object GetInstance(Type serviceType, string key)
{
string contract = string.IsNullOrEmpty(key) ? AttributedModelServices.GetContractName(serviceType) : key;
var exports = _container.GetExportedValues<object>(contract);
if (exports.Count() > 0)
return exports.First();
throw new Exception(string.Format("Could not locate any instances of contract {0}.", contract));
}
protected override IEnumerable<object> GetAllInstances(Type serviceType)
{
return _container.GetExportedValues<object>(AttributedModelServices.GetContractName(serviceType));
}
protected override void BuildUp(object instance)
{
base.BuildUp(instance);
_container.SatisfyImportsOnce(instance);
}