Null exception thrown when using ListContentOfContentType

Found in

EPiServer.Commerce 13.22.0

Fixed in

EPiServer.Commerce 13.30.0


Jan 18, 2021


Mar 09, 2021


Closed, Fixed and tested


This is a fix for an issue where null exception thrown when using ListContentOfContentType. 

Steps to reproduce:

  1. Install sample site (QuickSilver).
  2. Remove "FreeTextBlock" from the project and rebuild project
  3. Use code to list all content of type "FreeTextBlock".
var contentTypeRepository = ServiceLocator.Current.GetInstance<IContentTypeRepository>();
var contentModelUsage = ServiceLocator.Current.GetInstance<IContentModelUsage>();

var pageType = contentTypeRepository.Load("FreeTextBlock");
if (pageType != null)
   var contentUsages = contentModelUsage.ListContentOfContentType(pageType); // I get crash here

Expected: run successfully.

Actual: throw null exception.