Try our conversational search powered by Generative AI!

Calling IContentLoader in the constructor of scheduled job breaks typed model

Found in

EPiServer.CMS.Core 10.3.0

Fixed in

EPiServer.CMS.Core 10.4.1

(Or a related package)

Created

Jan 16, 2017

Updated

Jun 27, 2018

Area

CMS Core

State

Closed, Fixed and tested


Description

  • Create a scheduled job that calls IContentLoader in the constructor:

    public ScheduledJob() 
    { 
    var contentLoader = ServiceLocator.Current.GetInstance<IContentLoader>(); 
    var page = contentLoader.Get<ArticlePage>(new ContentReference(32)); 
    IsStoppable = true; 
    }
    

This is causing custom properties (like MainBody) on the model to not load correctly (they only exist in the Properties property, and are not set on the actual model).

Workaround: Do not call IContentLoader in constructor.