Hello, I try to get all pages of a certain doctype out of the repository and use the function TypedContentAtXPath for that, as it is just one call.
On a certain doctype it returns a result which is not null, but the results enumeration fails with a null pointer.
var pagesOfDoctype = Umbraco.ContentQuery.TypedContentAtXPath(string.Format("//{0}", doctypeNode.Alias));
foreach (var page in pagesOfDoctype)
{
...
}
The debugger shows the variable pagesOfDoctype as non-null linq variable, but the results view shows "Object reference not set to an instance of an object".
This looks like a umbraco bug, 2 questions:
1 How do I test for this case? Testing the results collection using
pagesOfDoctype.getEnumerator() == null
does not work
2 is TypedContentAtXPath considered legacy? ifyes the bug will not be fixed, what is the alternative?
I think I might be hitting the same problem... did you ever resolve this?
I'm working on a site where most calls to TypedContentAtXPath are working fine, but one in particular is throwing an exception "Object reference not set to an instance of an object" when I attempt to retrieve the results.
Stack Trace:
at Umbraco.Web.PublishedCache.XmlPublishedCache.XmlPublishedContent.Get(XmlNode node, Boolean isPreviewing)
at Umbraco.Web.PublishedCache.XmlPublishedCache.PublishedContentCache.<>c__DisplayClass1.<ConvertToDocuments>b__0(XmlNode xmlNode)
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at System.Linq.SystemCore_EnumerableDebugView`1.get_Items()
I'm running Umbraco 7.5.3. I've rebuilt my indexes, republished the entire site, deleted umbraco.config to try and rule out any possible problems in that regard, but with no luck. It does seem to be isolated to this particular document type!?
I just had the same issue on an Umbraco 7.6.4 instance.
I eventually found that one of my document types had a PROPERTY with the same alias as the document type alias I was trying to retrieve with TypedContentSingleAtXPath.
Renaming that property alias fixed the issue.
If you look at the XML in umbraco.config it actually makes perfect sense that having the same document type alias and property alias can cause these kinds of issues.
getting a null collection on TypedContentAtXPath
Hello, I try to get all pages of a certain doctype out of the repository and use the function TypedContentAtXPath for that, as it is just one call.
On a certain doctype it returns a result which is not null, but the results enumeration fails with a null pointer.
The debugger shows the variable pagesOfDoctype as non-null linq variable, but the results view shows "Object reference not set to an instance of an object".
This looks like a umbraco bug, 2 questions:
1 How do I test for this case? Testing the results collection using
does not work
2 is TypedContentAtXPath considered legacy? ifyes the bug will not be fixed, what is the alternative?
Hi,
I think I might be hitting the same problem... did you ever resolve this?
I'm working on a site where most calls to TypedContentAtXPath are working fine, but one in particular is throwing an exception "Object reference not set to an instance of an object" when I attempt to retrieve the results.
Stack Trace:
I'm running Umbraco 7.5.3. I've rebuilt my indexes, republished the entire site, deleted umbraco.config to try and rule out any possible problems in that regard, but with no luck. It does seem to be isolated to this particular document type!?
Any help from anyone would be appreciated!
nope, I just catch the exception and move on ;) good luck!
I just had the same issue on an Umbraco 7.6.4 instance.
I eventually found that one of my document types had a PROPERTY with the same alias as the document type alias I was trying to retrieve with
TypedContentSingleAtXPath
.Renaming that property alias fixed the issue.
If you look at the XML in umbraco.config it actually makes perfect sense that having the same document type alias and property alias can cause these kinds of issues.
Hi Arjan,
You can also do this in your xpath query :
All documents are have the isDoc attribute. So in case you have a property alias that is the same this will only get the documents
Dave
Thanks Dave, that's good to know.
Thank-you Dave, this cost me a few hours! Changing my query to:
Works like a charm!
is working on a reply...