Order in BootStraping

Sep 24, 2008 at 5:53 PM
Why is CreateShell() is called before InitializeModules() in UnityBootstrapper.Run(bool).
We want to disable creating shell based on condition evaluated by Service in one of the modules loaded.

Sep 24, 2008 at 6:51 PM



When a module is initialized, usually loads its views to the shell. For that reason the shell needs to be created before the modules start to be loaded. Perhaps you could evaluate your condition before running the Bootstrapper or in the CreateShell method without depending on a separate module.


Please let me know if this helps.


Mariano Converti

Sep 24, 2008 at 7:05 PM

Bear in mind that without the shell (you return null in CreateShell based on logic) that you won't have a RegionManager resolved to handle any views - when InitializeModules() is executed you'll need to ensure that none of the modules attempt to load views in regions. 

Excerpt from UnityBootstrapper.cs follows:

    logger.Log("Creating shell", Category.Debug, Priority.Low);
    DependencyObject shell = CreateShell();

    if (shell != null)
        RegionManager.SetRegionManager(shell, Container.Resolve<IRegionManager>());

    logger.Log("Initializing modules", Category.Debug, Priority.Low);

    logger.Log("Bootstrapper sequence completed", Category.Debug, Priority.Low);


Sep 24, 2008 at 7:33 PM
Condition evaluator in  our case to be specific SecuityManager is  part of the module  e.g. SecurityModule.
So when Security Module is loaded SecurityManager is instantiated, it checks some condition and Exits the Application if condition does not meet.
Now I can instantiate SecurityManager but in turn it(SecurityManager) needs other services in Same or may be different module.

BillKrat: I face similar situation in CreateShell. modules are not loaded yet so cannot instantiate SecurityManager
also I believe CreateShell should just create shell