Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ribbon control exception during page preview

Hi when loading page during preview I have not loaded ribbon. Do you have any clues how to fix it?

Object reference not set to an instance of an 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.NullReferenceException: Object reference not set to an instance of an object.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 


[NullReferenceException: Object reference not set to an instance of an object.]
   Sitecore.Data.Database.ApplySecurity(Item[] items) +112
   Sitecore.Data.Database.SelectItems(String query) +252
   Sitecore.Shell.Applications.WebEdit.Commands.OpenMyItems.GetHeader(CommandContext context, String header) +188
   Sitecore.Web.UI.WebControls.Ribbons.Ribbon.RenderSmallButton(HtmlTextWriter output, Item button, CommandContext commandContext) +307
   Sitecore.Web.UI.WebControls.Ribbons.Ribbon.RenderButton(HtmlTextWriter output, Item button, CommandContext commandContext) +732
   Sitecore.Web.UI.WebControls.Ribbons.Ribbon.RenderChunk(HtmlTextWriter output, Item chunk, CommandContext commandContext) +330
   Sitecore.Web.UI.WebControls.Ribbons.Ribbon.RenderChunk(HtmlTextWriter output, Item chunk, CommandContext commandContext, Boolean isContextual, String id) +204
   Sitecore.Web.UI.WebControls.Ribbons.Ribbon.RenderChunk(HtmlTextWriter output, Item chunk, CommandContext commandContext, Boolean isContextual) +242
   Sitecore.Web.UI.WebControls.Ribbons.Ribbon.RenderChunks(HtmlTextWriter output, Item strip, CommandContext commandContext, Boolean isContextual) +442
   Sitecore.Web.UI.WebControls.Ribbons.Ribbon.RenderStrips(HtmlTextWriter output, Item ribbon, Boolean isContextual, ListString visibleStripList) +800
   Sitecore.Web.UI.WebControls.Ribbons.Ribbon.RenderStrips(HtmlTextWriter output, Item defaultRibbon, Item contextualRibbon, ListString visibleStripList) +215
   Sitecore.Web.UI.WebControls.Ribbons.Ribbon.Render(HtmlTextWriter output) +610
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +149
   Sitecore.Web.HtmlUtil.RenderControl(Control ctl) +74
   Sitecore.Shell.Applications.WebEdit.WebEditRibbonForm.RenderRibbon(Item item) +603
   Sitecore.Shell.Applications.WebEdit.WebEditRibbonForm.OnLoad(EventArgs e) +1238

[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) +76
   System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +193
   System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) +35
   Sitecore.Web.UI.Sheer.ClientPage.OnLoad(EventArgs e) +337
   System.Web.UI.Control.LoadRecursive() +71
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3178
like image 854
Alexandr Avatar asked Aug 06 '13 17:08

Alexandr


3 Answers

From the stack trace information looks like the problem is with the My Items button in ribbon.

enter image description here

It seems that for some reason the fast query which is executed while loading this button returns a list of items which contain null. Do you have any custom data provider?

There are 2 solutions you can try:

  • clear cache on the /sitecore/admin/cache.aspx page
  • find the items which are causing the troubles by running this query as admin
Item[] items = Sitecore.Client.ContentDatabase.SelectItems(
    "fast://*[@__lock='%\"full-username-which-experienced-exception-with-domain-name\"%']");

The other option is to hide this button from ribbon (in core database remove or change security rights of /sitecore/content/Applications/WebEdit/Ribbons/WebEdit/Page Editor/Edit/My Items). From my experience this button is rarely used in the Page Editor mode and can slow down Page Editor as every time this mode is loaded, My items button counts all the articles which are locked by the current user so removing it might be a good idea anyway.

like image 55
Marek Musielak Avatar answered Jan 01 '23 10:01

Marek Musielak


I was experiencing the same issue in Sitecore 7 in page edit mode. I also verified the error occurred when clicking the "My Items" button in the content editor as well.

I found this post by Alex Shyba: http://sitecoreblog.alexshyba.com/2011/11/hidden-gem-of-sitecore-page-editor.html

His post suggests setting this setting in the web.config or better yet your include file:

<setting name="WebEdit.ShowNumberOfLockedItemsOnButton" value="false" />

This resolved the issue in the page editor for me and was clean and easy to implement. Hope this helps anyone else struggling with this as well.

like image 41
Nate Rickard Avatar answered Jan 01 '23 09:01

Nate Rickard


Using 7.1 this error started when I restored the databases from backups on another machine. I was able to resolve it by rebuilding the search index:

Desktop > Control Panel > Databases > Rebuild the Search Index

I also cleaned up the databases and rebuilt the link database, but those didn't seem to fix it.

like image 36
RCrowe Avatar answered Jan 01 '23 09:01

RCrowe