«No parameterless constructor defined for this object.» exception after upgrade to Episerver CMS 11

After upgrading a site from CMS 10 to CMS 11 I was faced by this exception:
No parameterless constructor defined for this object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.MissingMethodException: No parameterless constructor defined for this object.

Edit and admin mode works, but every page returns this YSOD (yellow screen of death) exception page.

In the middle of the list of breaking changes for CMS 11 there is a clue:

It is no longer supported to get an ILogger instance from IOC container.

In every page controller, I had:

private readonly ILogger _log;

public DefaultPageController(ILogger logger)
   _log = logger;

Replacing this with:

private readonly ILogger _log = LogManager.GetLogger();

public DefaultPageController()

…resolves the issue.

Legg igjen en kommentar

Din e-postadresse vil ikke bli publisert. Obligatoriske felt er merket med *