2

We have upgraded to Sitecore 10.1 from Sitecore 8.2. The Creative Exchange feature is giving object null reference error in web database when creating a new site using powershell script.

How to reproduce the error.

  1. Create a new sxa site
  2. Check the Creative Exchange under modules

creative exchange

  1. Publish the new site to web database.
  2. Open the Home item of new created website in the web database and object null reference error will appear.

The error only appears when a new sxa site is created with Creative Exchange module.

Object null reference

[NullReferenceException: Object reference not set to an instance of an object.]
   Sitecore.XA.Foundation.Theming.ThemingContext.GetThemeItem(Item item, DeviceItem device) +143
   Sitecore.XA.Feature.CreativeExchange.Commands.CreativeExchangeCommandBase.QueryState(CommandContext context) +315
   Sitecore.Shell.Framework.Commands.CommandManager.QueryState(Command command, CommandContext context) +36
   Sitecore.Web.UI.WebControls.Ribbons.Ribbon.FillParamsFromCommand(CommandContext commandContext, RibbonCommandParams ribbonCommandParams) +220
   Sitecore.Web.UI.WebControls.Ribbons.Ribbon.GetCommandParameters(Item controlItem, CommandContext commandContext) +78
   Sitecore.Web.UI.WebControls.Ribbons.Ribbon.RenderLargeButton(HtmlTextWriter output, Item button, CommandContext commandContext) +77
   Sitecore.Web.UI.WebControls.Ribbons.Ribbon.RenderButton(HtmlTextWriter output, Item button, CommandContext commandContext) +439
   Sitecore.Web.UI.WebControls.Ribbons.Ribbon.RenderChunk(HtmlTextWriter output, Item chunk, CommandContext commandContext) +347
   Sitecore.Web.UI.WebControls.Ribbons.Ribbon.RenderChunk(HtmlTextWriter output, Item chunk, CommandContext commandContext, Boolean isContextual, String id) +243
   Sitecore.Web.UI.WebControls.Ribbons.Ribbon.RenderChunk(HtmlTextWriter output, Item chunk, CommandContext commandContext, Boolean isContextual) +160
   Sitecore.Web.UI.WebControls.Ribbons.Ribbon.RenderChunks(HtmlTextWriter output, Item strip, CommandContext commandContext, Boolean isContextual) +431
   Sitecore.Web.UI.WebControls.Ribbons.Ribbon.RenderStrips(HtmlTextWriter output, Item ribbon, Boolean isContextual, ListString visibleStripList) +1621
   Sitecore.Web.UI.WebControls.Ribbons.Ribbon.RenderStrips(HtmlTextWriter output, Item defaultRibbon, Item contextualRibbon, ListString visibleStripList) +161
   Sitecore.Web.UI.WebControls.Ribbons.Ribbon.Render(HtmlTextWriter output) +739
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +131
   Sitecore.Web.HtmlUtil.RenderControl(Control ctl) +79
   Sitecore.Shell.Applications.ContentManager.ContentEditorForm.UpdateRibbon(Item folder, Boolean isCurrentItemChanged, Boolean showEditor) +559
   Sitecore.Shell.Applications.ContentManager.ContentEditorForm.Update() +581
   Sitecore.Shell.Applications.ContentManager.ContentEditorForm.OnPreRendered(EventArgs e) +191

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) +0
   System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) +132
   System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +146
   Sitecore.Reflection.ReflectionUtil.InvokeMethod(MethodInfo method, Object[] parameters, Object obj) +89
   Sitecore.Shell.Applications.ContentManager.ContentEditorPage.OnPreRender(EventArgs e) +143
   System.Web.UI.Control.PreRenderRecursiveInternal() +200
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +7479

Has anyone encountered this issue?

Thanks in advance .

5
  • Did you publish your theme? Perhaps that would help? The exception suggests the theme cannot be found but the command should not be evaluated on the web database in the first place... Apr 5, 2022 at 7:16
  • yeah the theme is published @SzymonKuzniak Apr 5, 2022 at 7:23
  • Can you check if item with ID {79C7FE02-185A-4576-B5A8-5B0AC10DB0CB} is available in web database? Apr 5, 2022 at 11:42
  • @SzymonKuzniak thanks , that fixed the issue. Apr 6, 2022 at 4:25
  • I have added this as an answer so if others will come to this page they could easily find it (nobody will search for an answer in comments). Can you please accept it, so it's immediately visible that this solves the problem? Apr 6, 2022 at 8:05

1 Answer 1

2

GetThemeItem method is dependant on theme mode item with ID {79C7FE02-185A-4576-B5A8-5B0AC10DB0CB}. Make sure this item is published.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.