LOL, I was 3 mins too late, hehe, solution is basically the same, you also made me realise you don't need to set the MainWindow to null as the framwork won't set it if the ShutdownMode is
ShutdownMode.OnExplicitShutdow. I also like your approach as you start up and register the container which means login services could be plugged in.
I'll probably base your solution on within my Late Night sample.
Here is what I am doing to show a login dialog before the Shell.
nb I am using CastleWindsor as my container - Unity will work just as well. I am using the trunk version of Windsor.
Also I have overriden CreateContainer in Bootrapper to return the container I pass in in Bootstrapper's constructor
protected override void OnStartup(StartupEventArgs e)
bool shutdown = true;
//initialize container with components necessary for login dialog
IWindsorContainer container = new WindsorContainer();
Endpoint = WcfEndpoint
//create & show login dialog
var loginDialog = container.Resolve<Login.LoginDialog>();
bool? ok = loginDialog.ShowDialog();
//was ok button clicked?
if (ok ?? false)
//was user validated?
if (loginDialog.ValidateUserResult == ValidateUserResult.Ok)
//user validated - show shell - do not shutdown
shutdown = false;
Application.Current.ShutdownMode = ShutdownMode.OnMainWindowClose;
//pass container to bootstrapper
Bootstrapper bootstrapper = new Bootstrapper(container);