Posted on:
Categories: PowerShell;SharePoint
Description:

​Recently, I added a Content Query Web Part (CQWP) to a new page residing on a fresh instance of a SP2013 site collection. This site collection was created using the Developer Site template to allow for side-loading add-ins developed and deployed directly from Visual Studio. 

When accessing the web part settings, I encountered a generic error page with "Sorry, something went wrong. An unexpected error has occurred." 

Looking at the ULS logs using ULSViewer.exe, I found some logs that may point to the cause of the issue: 

​ConsoleUtilies.GetContextualControlMode had no currentPage so the current SPWebPartManager mode cannot be retrieved.

Application error when access /sites/appdev/SitePages/Home.aspx, Error=Key cannot be null.  Parameter name: key   at System.Collections.SortedList.IndexOfKey(Object key)     at System.Collections.SortedList.ContainsKey(Object key)     at Microsoft.SharePoint.Publishing.WebControls.ContentByQueryToolPart.AppendListTypes(SortedList sortedListItems, SPListTemplateCollection listTypes)     at Microsoft.SharePoint.Publishing.WebControls.ContentByQueryToolPart.populateListTypeDropDown()     at Microsoft.SharePoint.Publishing.WebControls.ContentByQueryToolPart.populateCBQControls()     at Microsoft.SharePoint.Publishing.WebControls.ContentByQueryToolPart.OnPreRender(EventArgs e)     at System.Web.UI.Control.PreRenderRecursiveInternal()     at System.Web.UI.Control.PreRenderRecursiveInternal()     at System.Web.UI.Control.PreRenderRecursiveInternal()     at System.Web.UI.Control.PreRenderRecursiveInternal()     at System.Web.UI.Control.PreRenderRecursiveInternal()     at System.Web.UI.Control.PreRenderRecursiveInternal()     at System.Web.UI.Control.PreRenderRecursiveInternal()     at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

With a bit of Google-fu, I found these links that discusses this issue and the possible fixes: 


Based on the suggestions in the links, I disabled the Developer Site Collection Feature using this command in the SharePoint 2013 Management Shell and confirmed that the issue is resolved:
Disable-SPFeature -identity  "E374875E-06B6-11E0-B0FA-57F5DFD72085" -URL <SiteUrl>