Results from TypedContentAtXpath() throw exception when enumerated
Hi guys,
Hoping you can help me here. I'm grabbing all IPublishedContent of a particular document type using Umbraco.TypedContentAtXPath("//docType"); This works fine and seems to return an IEnumberable
[NullReferenceException: Object reference not set to an instance of an object.]
Umbraco.Web.PublishedCache.XmlPublishedCache.XmlPublishedContent.Get(XmlNode node, Boolean isPreviewing) +94
System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +222
It's almost as if there is an entry in the Umbraco XML cache that doesn't exist in the database. I've tried clearing the app data folder. Recyling the app pool, performing a republish all but none of these have helped.
There's definitely something wrong with the IPublishedContent collection that is coming back from Umbraco because performing .ToList() and .Count() methods on it both throw a similar error.
Can't say I have experienced that :-| Would be great with a little more information.
Are the indexes ok?
Does Data integrity check pass?
What Umbraco version are you running?
Is that the full error message?
Finally, are there items in the recycle bin? If so could you try deleting them and see if that helps? Seem to remember that causing an issue at some point.
var ttAuthors = Umbraco.TypedContentAtXPath( "//author" );
foreach ( IPublishedContent author in ttAuthors ) {
if ( author != null ) {
if ( author.Name == pm.MentorName ) {
matchingAuthor = author;
break;
}
}
}
I can happily step through the foreach statment in the debugger for several content items until it throws an error when attempting to get the next IPublishedContent item out of the collection.
I already checked the recycle bin too! It's completely empty as far as I can tell.
The site is running on Umbraco version 7.5.0 assembly: 1.0.6073.15895
Is there anywhere I can check in the cms/umbraco tables to see what might be going wrong?
I recognise this is an old thread, but if anyone has the same issue, make sure none of your document types have a property with an alias matching the document type alias you are trying to retrieve. It's easiest to find in the XML cache in App_Data/umbraco.config
Results from TypedContentAtXpath() throw exception when enumerated
Hi guys,
Hoping you can help me here. I'm grabbing all IPublishedContent of a particular document type using Umbraco.TypedContentAtXPath("//docType"); This works fine and seems to return an IEnumberable
It's almost as if there is an entry in the Umbraco XML cache that doesn't exist in the database. I've tried clearing the app data folder. Recyling the app pool, performing a republish all but none of these have helped.
There's definitely something wrong with the IPublishedContent collection that is coming back from Umbraco because performing .ToList() and .Count() methods on it both throw a similar error.
Please help!
Thanks, Matt.
Hi Matt
Can't say I have experienced that :-| Would be great with a little more information.
All the best
Rune
Thanks for taking the time to reply Rune.
I had already tried rebuilding the indexes, it doesn't seem to make a difference.
The data integrity check comes back as ok.
The full error message is:
The code I'm running is:
I can happily step through the foreach statment in the debugger for several content items until it throws an error when attempting to get the next IPublishedContent item out of the collection.
I already checked the recycle bin too! It's completely empty as far as I can tell.
The site is running on Umbraco version 7.5.0 assembly: 1.0.6073.15895
Is there anywhere I can check in the cms/umbraco tables to see what might be going wrong?
Cheers, Matt.
I recognise this is an old thread, but if anyone has the same issue, make sure none of your document types have a property with an alias matching the document type alias you are trying to retrieve. It's easiest to find in the XML cache in App_Data/umbraco.config
See also my response here: https://our.umbraco.com/forum/developers/api-questions/75694-getting-a-null-collection-on-typedcontentatxpath#comment-295954
Hi Chris,
that makes a whole bunch of sense and is most likely the reason for the error described above.
Thanks for taking the time to reply to an old thread - Really helpful!
h5yr 🙌
/rune
is working on a reply...