Hi,
I believe that Damian was referring to overriding the Run method and copying the original Run method code with your modifications like this:
In your case, you were receiving that System.NullReferenceException because the ServiceLocator was never initialized in your Run method.
Hope this helps,
Federico Martinez
http://blogs.southworks.net/fmartinez
I believe that Damian was referring to overriding the Run method and copying the original Run method code with your modifications like this:
publicoverridevoid Run(bool runWithDefaultConfiguration) { this.useDefaultConfiguration = runWithDefaultConfiguration; this.Logger = this.CreateLogger(); if (this.Logger == null) { thrownew InvalidOperationException(Resources.NullLoggerFacadeException); } this.Logger.Log(Resources.LoggerCreatedSuccessfully, Category.Debug, Priority.Low); this.Logger.Log(Resources.CreatingModuleCatalog, Category.Debug, Priority.Low); this.ModuleCatalog = this.CreateModuleCatalog(); if (this.ModuleCatalog == null) { thrownew InvalidOperationException(Resources.NullModuleCatalogException); } this.Logger.Log(Resources.ConfiguringModuleCatalog, Category.Debug, Priority.Low); this.ConfigureModuleCatalog(); this.Logger.Log(Resources.CreatingUnityContainer, Category.Debug, Priority.Low); this.Container = this.CreateContainer(); if (this.Container == null) { thrownew InvalidOperationException(Resources.NullUnityContainerException); } this.Logger.Log(Resources.ConfiguringUnityContainer, Category.Debug, Priority.Low); this.ConfigureContainer(); this.Logger.Log(Resources.ConfiguringServiceLocatorSingleton, Category.Debug, Priority.Low); this.ConfigureServiceLocator(); this.Logger.Log(Resources.ConfiguringRegionAdapters, Category.Debug, Priority.Low); this.ConfigureRegionAdapterMappings(); this.Logger.Log(Resources.ConfiguringDefaultRegionBehaviors, Category.Debug, Priority.Low); this.ConfigureDefaultRegionBehaviors(); this.Logger.Log(Resources.RegisteringFrameworkExceptionTypes, Category.Debug, Priority.Low); this.RegisterFrameworkExceptionTypes(); this.Logger.Log(Resources.CreatingShell, Category.Debug, Priority.Low); this.Shell = this.CreateShell(); if (this.Shell != null) { this.Logger.Log(Resources.SettingTheRegionManager, Category.Debug, Priority.Low); RegionManager.SetRegionManager(this.Shell, this.Container.Resolve<IRegionManager>()); this.Logger.Log(Resources.UpdatingRegions, Category.Debug, Priority.Low); RegionManager.UpdateRegions(); this.Logger.Log(Resources.InitializingShell, Category.Debug, Priority.Low); this.InitializeShell(); } if (this.Container.IsRegistered<IModuleManager>()) { //Patch to wait for the userPrincipal before initializing the modulesif (userPrincipal.UserID == 0) { ServiceLocator.Current.GetInstance<IEventAggregator>().GetEvent<UserInitialized>().Subscribe(this.UserDone); } else { this.Logger.Log(Resources.InitializingModules, Category.Debug, Priority.Low); this.InitializeModules(); this.Logger.Log(Resources.BootstrapperSequenceCompleted, Category.Debug, Priority.Low); } } } publicvoid UserDone(UserPrincipal user) { ServiceLocator.Current.GetInstance<IEventAggregator>().GetEvent<UserInitialized>().Unsubscribe(this.UserDone); this.Logger.Log(Resources.InitializingModules, Category.Debug, Priority.Low); this.InitializeModules(); this.Logger.Log(Resources.BootstrapperSequenceCompleted, Category.Debug, Priority.Low); }
Hope this helps,
Federico Martinez
http://blogs.southworks.net/fmartinez