Presentation Details dialog throws null reference exception – Sitecore 8

Reason

When opening the Presentation Details dialog for an item (e.g. the Standard Values for a template) a null reference exception is thrown.

[ArgumentNullException: Value cannot be null. Parameter name: value]
   Sitecore.Diagnostics.Assert.ArgumentNotNull(Object argument, String argumentName) +105
   Sitecore.Web.WebUtil.SafeEncode(String value) +84
   Sitecore.Shell.Applications.Layouts.DeviceEditor.DeviceEditorForm.RenderRenderings(DeviceDefinition deviceDefinition, Int32 selectedIndex, Int32 index) +1682
   Sitecore.Shell.Applications.Layouts.DeviceEditor.DeviceEditorForm.Refresh() +622
   Sitecore.Shell.Applications.Layouts.DeviceEditor.DeviceEditorForm.OnLoad(EventArgs e) +703

The issue arises when the placeholder XML-attribute (“ph”) is missing from one or more of the elements in the “Renderings”-field.
I honestly can’t say when or why some of the “ph”-attributes went missing, as the solution in question is 2+ years old and started out as Sitecore 6.6 Update-2. All I know is that earlier versions of Sitecore handled the circumstance gracefully.
If you know what causes this issue, please leave a comment 🙂

This article is based on a Sitecore 8 Update-2 (rev. 150223).

Code

To fix the problem, follow these steps:

  1. Open the “View” tab and check “Standard fields” and “Raw values”.
    Required view settings.
  2. Copy the contents of the “Renderings”-field into a text editor, e.g. Visual Studio.
    Renderings field raw values.
  3. Search for any “r”-elements which do not contain a “ph”-attribute.
    Lines missing the 'ph' attribute
  4. Add an empty “ph”-attribute to these elements.
    'ph' attribute fixed
  5. Copy and paste the modified XML back into the “Renderings”-field.
  6. Save the item.

Example

A video of how to reproduce and solve this issue can be found here.

3 thoughts on “Presentation Details dialog throws null reference exception – Sitecore 8

  1. Thank for this post, Uli! It definitely fixed my issue.

    But after I manually added the “ph” attributes to my layout XML and this fixed my issue, now, if I remove the “ph” attributes, I can’t reproduce the issue anymore! 🙂 Once I put in the “ph” attributes, I can remove them and I no longer get the issue. In other words, I can put the XML back to exactly what it was when I was getting the error you mentioned and I don’t get the error anymore!

    Any idea why?

    I’m inclined to open a ticket with Sitecore Support because this issue is still happening with the latest version of Sitecore 8.1, rev. 160302.

    • Hi Douglas,

      I’d say opening a ticket is the right thing to do, especially considering the amount of people hitting this issue – I can see that it’s quite a few simply by looking at the visit count on this very blog post!

      I’m out of the loop reg. Sitecore and can’t really help with any further insight – I’ve switched jobs and am no longer working with Sitecore CMS.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s