Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Null exception thrown when using ListContentOfContentType

Found in

EPiServer.Commerce 13.22.0

Fixed in

EPiServer.Commerce 13.30.0

(Or a related package)

Created

Jan 18, 2021

Updated

Mar 09, 2021

State

Closed, Fixed and tested


Description

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.