Unable to invoke bootstrapper with out App.xaml.

Topics: Bootstrappers & IoC, Bugs, Extensibility, Getting Started, UI Architecture
Sep 14, 2015 at 12:06 PM
Hi
Recently working on caliburn micro and want to create class libraries with caliburn micro and use them in another tool. But when i try to invoke bootstrpper object using the Start() it is not binding my views and viewmodel.
TestBootStrapper tb = new TestBootStrapper();
            tb.Start();
And i want to display it as showdialog but that is also not happening. Please guide me on this.
Is there any way to bootstrap with out App.Xaml ?

namespace xxxxxxx
{
public class TestBootStrapper : BootstrapperBase
{
    public TestBootStrapper():base(false)
    {
        StartRuntime();
         Start();

    }

    private CompositionContainer container;

    protected override void Configure()
    {
        container = new CompositionContainer(new AggregateCatalog(AssemblySource.Instance.Select(x => new AssemblyCatalog(x)).OfType<ComposablePartCatalog>()));

        CompositionBatch batch = new CompositionBatch();

        batch.AddExportedValue<IWindowManager>(new AppWindowManager());
        batch.AddExportedValue<IEventAggregator>(new EventAggregator());
        batch.AddExportedValue(container);

        container.Compose(batch);
    }

    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<Assembly> SelectAssemblies()
    {
        return new[] {
            Assembly.GetExecutingAssembly()
                        };
    }

    protected override void OnStartup(object sender, System.Windows.StartupEventArgs e)
    {
        base.OnStartup(sender, e);
        DisplayRootViewFor<MainViewModel>();

    }

}
}