Console application and caliburn micro

Topics: Bootstrappers & IoC
Mar 28, 2012 at 4:26 PM

 

Hello,

I've got a problem.. in a WPF application I use Caliburn micro and for showing reports I used IoC to get the application repository... now I've been asked to generare reports in batch but I'm not able to have the IApplicationRepository get registered within the console application...

 

private void Compose()

{

    CompositionHost.IgnorePatterns.Add("Aspose.Pdf.Kit");

 

    var catalog = new AggregateCatalog();

    catalog.Catalogs.Add(new DirectoryCatalog(@"."));

    catalog.Catalogs.Add(new AssemblyCatalog(typeof(Program).Assembly));

 

    var container = new CompositionContainer(catalog);

 

    container.ComposeParts(this);

    container.SatisfyImportsOnce(this);

    var a = IoC.Get<IApplicationRepository>();

}

What am I doing wrong?

Thanks

Apr 5, 2012 at 12:06 PM

Please someone help me on this... even a simple example would be great... I've tried a lot but I've no enougth competence to succede alone...

Apr 6, 2012 at 9:44 PM
Edited Apr 6, 2012 at 9:46 PM

I'm not sure if this will help, but to enable a commandline and a UI mode in the project I'm working on, I had to override the OnStartup for my commandline bootstrapper. My other overrides are bascially the same as what's in the HelloMEF sample.

 

 

public class CmdLineBootstrapper : Bootstrapper<IShell>
{
        protected override void OnStartup(object sender, StartupEventArgs e)
        {
            var shell = IoC.Get<ShellViewModel>();
            shell.OnInitCmdLine();
            App.Current.Shutdown();
        }
}