Error when deleting a Content/Data item (Content Type) - Fixable without uninstall?

Jun 22, 2015 at 8:32 PM
A Content Type was deleted that was still in use on a page. Clicking on the View/Templates Tab in edit mode shuts down the module and throws this error -
DotNetNuke.Services.Exceptions.PageLoadException: The given key was not present in the dictionary. ---> System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at ToSic.Eav.Data.EntityRelationship.<GetEnumerator>b__2(Nullable`1 l)
   at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at ToSic.Eav.Data.EntityRelationship.GetEnumerator()
   at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
   at ToSic.SexyContent.Template.get_ContentDemoEntity()
   at ToSic.SexyContent.ManageTemplates.<BindGrdTemplates>b__6(<>f__AnonymousType22`2 <>h__TransparentIdentifier0, IContentType a)
   at System.Linq.Enumerable.<SelectManyIterator>d__31`3.MoveNext()
   at Telerik.Web.UI.GridDataTableFromEnumerable.FillData()
   at Telerik.Web.UI.GridResolveEnumerable.EnsureInitialized()
   at Telerik.Web.UI.GridEnumerableFromDataView..ctor(GridTableView owner, IEnumerable enumerable, Boolean CaseSensitive, Boolean autoGenerateColumns, GridColumnCollection presentColumns, String[] additionalField, Boolean retrieveAllFields, Boolean enableSplitHeaderText)
   at Telerik.Web.UI.GridDataSourceHelper.CreateGridEnumerable(GridTableView owner, IEnumerable enumerable, Boolean caseSensitive, Boolean autoGenerateColumns, GridColumnCollection presentColumns, String[] additionalField, Boolean retrieveAllFields, Boolean enableSplitHeaderText)
   at Telerik.Web.UI.GridTableView.get_ResolvedDataSource()
   at Telerik.Web.UI.GridTableView.CreateChildControls(IEnumerable dataSource, Boolean useDataSource)
   at System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data)
   at System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data)
   at Telerik.Web.UI.GridTableView.PerformSelect()
   at Telerik.Web.UI.GridTableView.DataBind()
   at ToSic.SexyContent.ManageTemplates.Page_Load(Object sender, EventArgs e)
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

   --- End of inner exception stack trace ---
I saw the same issue on the 2sxc CodePlex Forum but it went unanswered and seems it could only be fixed by an uninstall and reinstall. See here

Uninstalling and reinstalling isn't really an option we want to take if we don't have to. Is there another way to fix this? Can we try to find and delete the entity in the database?

Any help is appreciated!
  • Margie
Coordinator
Jun 23, 2015 at 6:15 AM
@Margie

What version of 2sxc are you using - the solution is different for 6 and 7?

Here's the power-hack which will probably help you in Version 7:
  • The templates (in 2sxc 7) are also content-items in the EAV system - you just don't see them because they are hidden on purpose
  • Go to Admin > Content /Data - open that IFrame in a new page. You'll get a url a bit like /YourPage/ctl/eavmanagement/mid/417/AppId/10?popUp=true
  • add this to the end of the url: &scope=2SexyContent-System
  • ...that will cause the page to show you content-types for that. In here you should be able to edit the content-item without the custom UI - or you could also just delete it so that you can then re-create the template definition in the normal UI
Note that this kind of action is not recommended to anybody else - since you're directly working with internal system data. It will invalidate your warrant :)

Love from Switzerland
Daniel
Jun 23, 2015 at 7:06 PM
@Daniel

Thank you for your quick response!

I am indeed using Version 7.

I followed your instructions but was unsure of which content-item to edit or delete as it is a list of numbers and the templates connected didn't give me any hints as to which one it was. I ended up removing the template and content selections from each content type without luck. I may just go ahead and delete all of the content types from this interface that I made and set each one up again in the normal UI.

Is there something I am missing? What would you suggest?
  • Margie
Jun 23, 2015 at 8:30 PM
@Daniel

Also, in Apps Management, the Content app - with App ID 4 - is greyed out and says that it is hidden. There doesn't seem to be a way to change this. I was not sure if this was a cause of the issue or if it was a byproduct of the content type deletion.

I ended up deleting the possible content-items - but I'm still getting the error.
  • Margie
Coordinator
Jun 24, 2015 at 6:18 AM
@Margie

The Content-App cannot be deleted because that actually the normal content of the site - and you can't kill it completely :).

As to your issue - maybe you're fixing the wrong issue. Just to be precise in terminology
  • A content-item is 1 item, like a person, a simple-content etc.
  • A Content-Type is a schema - like the description that a Person contains a Name, FirstName, LastName, Birthday etc.
Now I'm pretty certain you deleted a content-item, not a content-type - but do correct me if I'm wrong.
You also edited various template-content-items (not the template-content-type) - again pls correct me if I'm wrong.

Now please give me a more precise description of what fails
  • you can add/edit content normally...
  • except for one where the template uses the deleted content-item
  • and you can't go into manage-templates, because that view fails - and you assume it's because that one item was removed
is that correct?
Jun 25, 2015 at 7:52 PM
@Daniel

I believe we are on the same page with terminology. It was a Content-Type that was deleted with content-items using the schema that were still on a page when it was deleted.

I edited and then deleted some entries in the Content-ContentGroup tab in the 2SexyContent-System interface believing one of those to be the template connection to my Content-Type.
I also went into the Content-Template tab and deleted any templates that I thought may have been using the deleted Content-Type.
  • I can add/edit content normally.
  • Except when I go into Views / Templates the page fails and the interface closes and throws the error.
  • It does this with any content-item.
My assumption is based on the fact that this problem started to occur right after the Content-Type was deleted but it may be something else that went wrong.

Thanks for your patience.