Not sure, it will solve your problem documentation says you should add dependency on PackagingInitialization (Derived class should be marked with ModuleDependencyAttribute with dependency on PackagingInitialization.))
Just another pointer, Are you aware of "TerminateInitializationException"?
Check this link as well
https://world.episerver.com/blogs/Magnus-Strale/Dates/2009/12/The-new-initialization-system---How-to-write-an-initialization-module-and-advanced-topics/
No I was not aware. How can it be used?
Like this?
if (SiteDefinition.Current.SiteUrl == null) { throw new TerminateInitializationException(); }
Effectively yes. See the URL that I pasted in last post. He is doing the same thing as you are...
I have seen it, but am not aware of the methods he is calling>
var section = EPiServerFrameworkSection.Instance; InitializeFromConfig(section.SiteHostMapping); var configSiteId = SiteIdFromConfig(section); // Get info from config file / var actualSiteId = SiteIdFromRequest();
"InitializeFromConfig", "SiteIdFromConfig" and "SiteIdFromRequest"
You should use the interface instead
var siteDefinitionRepository = ServiceLocator.Current.GetInstance<ISiteDefinitionRepository>();
var siteDefinitions = siteDefinitionRepository.List().ToList();
We are trying to acces `SiteDefinition.Current` at the time of `AfterInstall`. What we need is `SiteUrl` and `Id` but it seems that at the time of this event they are not available.
How can we postpone the calling of `AfterInstall` or otherwise, could we attach an event listener in `AfterInstall` that can later in the pipeline provide us the data?
Update:
From what I can see in the documentation and from here (enumerating the order of the execution of dependencies), decorating the class like the following should have EPiServer.Web initialized, and by extent, SiteDefinition.Current.
Decorated the class like bellow with no results.