Try our conversational search powered by Generative AI!

Area: Optimizely CMS
Applies to versions: 12 and higher
Other versions:
ARCHIVED This content is retired and no longer maintained. See the version selector for other versions of this topic.

Creating an initialization module

Recommended reading 
Note: This documentation is for the preview version of the upcoming release of CMS 12/Commerce 14/Search & Navigation 14. Features included here might not be complete, and might be changed before becoming available in the public release. This documentation is provided for evaluation purposes only.

This topic describes how to create an initialization module to work with the initialization system in the Optimizely platform.

How it works

When you create your own initialization module, add a reference to EPiServer.Framework.dll. The following Initialization code example shows how a property is set up with a default implementation in Initialize and then the process is undone in Uninitialize:

public class SampleInitialization : IInitializableModule
    public void Initialize(InitializationEngine context)
    public void Uninitialize(InitializationEngine context)


  1. The initialization engine makes sure that your code executes in a single-threaded manner.
    You do not need to lock regions when you deal with shared state. This guarantee is only made for Initialize and Unintialize when you execute through the initialization system. If you have custom code that makes calls directly into your initialization module, then you may need to deal with multi-threading issues.
  2. Remember that the initialization system tracks the initialization state of your module.
  3. Do an implementation of Uninitialize.
    Anything you do with Initialize you should undo with Uninitializein the reverse order of Initialize. This is especially important if you write integration tests that reset application between test runs.
  4. If you are using the CMS API make sure you are adding a module dependency to CMS using [ModuleDependency(typeof(EPiServer.Web.InitializationModule))].

Related topic

Do you find this information helpful? Please log in to provide feedback.

Last updated: Jul 02, 2021

Recommended reading