AI OnAI Off
It seems you might have a faulty root.
If you run this code, what root gives you the exception
var roots = _contentRepositoryDescriptors.SelectMany(descriptor => descriptor.Roots).Distinct().ToList();
var filteredRoots = new List<ContentReference>();
foreach (var root in roots)
{
var ancestors = _contentLoader.GetAncestors(root);
if (!ancestors.Any(ancestor => roots.Contains(ancestor.ContentLink)))
{
filteredRoots.Add(root);
}
}
The page that is throwing the exception is under the Root node, i.e. the "Home - Site Settings" node shown below:
I've tried a variation of your code (see below) to select the pages under the root, no exceptions were thrown.
var subRoots = _contentRepository.GetChildren<PageData>(ContentReference.RootPage, LanguageSelector.MasterLanguage()).ToList();
var filteredRoots = new List<ContentReference>();
foreach (var root in subRoots)
{
var ancestors = _contentLoader.GetAncestors(root.ContentLink);
if (!ancestors.Any(ancestor => subRoots.Contains(ancestor)))
{
filteredRoots.Add(root.ContentLink);
}
}
I think i've found part of the issue; reinitializing that node has made the dotnet exception go away.
Have a site running on CMS 12.29.0 and have the following exception thrown when trying to view one of the nodes in my content tree: