November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
Hi,
All ServiceLocator dependencies are registired in EPiServer.ServiceLocation.ServiceContainerInitialization module which is executed very early (this is one of the first InitializableModule).
It looks like the EPiServer.Web.InitializationModule is the latest executed EPiServer module. So I think that your ModuleDependency is correct.
I tried to use ContentLanguage.PreferredCulture.Name inside module on the Alloy site and it's working.
Do you using any other dependencies resolved through ServiceLocator? Are they working?
Hi,
ServiceLocator is working in our project, yes.
I am setting our DependencyResolver depending on language. Here is the class:
[ModuleDependency(typeof(EPiServer.Web.InitializationModule))] [InitializableModule] public class DependencyResolverInitialization : IConfigurableModule { public void ConfigureContainer(ServiceConfigurationContext context) { context.Container.Configure(ConfigureContainer); DependencyResolver.SetResolver(new StructureMapDependencyResolver(context.Container)); } private static void ConfigureContainer(ConfigurationExpression container) { //Swap out the default ContentRenderer for our custom container.For<IContentRenderer>().Use<ErrorHandlingContentRenderer>(); container.For<ContentAreaRenderer>().Use<ContentAreaRenderer>(); //Use ContentLanguage.PreferredCulture.Name here. } public void Initialize(InitializationEngine context) { } public void Uninitialize(InitializationEngine context) { } public void Preload(string[] parameters) { }
Above, ContentLanguage does not work in ConfigureContainer function. Other examples I have seen the class inherited from IInitializableModule. But if I do, I can't get context.Container.
I think that when you configure container through IConfigurableModule you should use some "earlier" module dependency like:
[ModuleDependency(typeof(EPiServer.Shell.ShellInitialization))]
but I'm not sure if it's related with your problem
That didn't work.
"ConfigureContainer is called on all IInitializableModule before initialization begins. This allows modification of the container before service instances are created during initialization."
At this stage It seems like I can't work with ServiceLocator at all.
Hi,
In my class with InitializableModule attribute I need to use ContentLanguage.PreferredCulture.Name.
My dependency is:
[ModuleDependency(typeof(EPiServer.Web.InitializationModule))]
Error:
No default Instance is registered and cannot be automatically determined for type 'EPiServer.DataAbstraction.ILanguageBranchRepository'
There is no configuration specified for EPiServer.DataAbstraction.ILanguageBranchRepository
1.) Container.GetInstance(EPiServer.DataAbstraction.ILanguageBranchRepository)
Any idea what other dependency to use, or other idea to get ContentLanguage to work at this stage.
Thanks!