After running the 7.5.11 upgrade on our Umbraco web site I am getting an exception in one of my Partial View Macro Files (cshtml):
System.NullReferenceException: Object reference not set to an instance of an object.
at Umbraco.Web.PublishedContentExtensions.GetPropertyValue(IPublishedContent content, String alias)
The exception is pointing to this line:
var mediaItem = Umbraco.TypedMedia(item.GetPropertyValue("propAliasString"));
I had a 'similar' issue in the past. Previously i was expecting a single result from a data type in an earlier version of umbraco, when i copied the code to a newer project, it failed. This was because the data type was not returning a collection instead of a single instance. I would check if that is the issue first.
Secondly, i would do a little bit of defensive work - check if the item has the property and value for the item you want (announcement). Then check to see if it actually does return anything.
Exception after upgrading to 7.5.11 from 7.4.3
After running the 7.5.11 upgrade on our Umbraco web site I am getting an exception in one of my Partial View Macro Files (cshtml):
The exception is pointing to this line:
The line is in this foreach loop:
I have tried to browse the Umbraco documentation for changes in the api from 7.4 to 7.5 regarding this issue.
Before the upgrade this worked.
Has any of you experienced this kind of error? - and more important found a solution?
best regards Jesper
I had a 'similar' issue in the past. Previously i was expecting a single result from a data type in an earlier version of umbraco, when i copied the code to a newer project, it failed. This was because the data type was not returning a collection instead of a single instance. I would check if that is the issue first. Secondly, i would do a little bit of defensive work - check if the item has the property and value for the item you want (announcement). Then check to see if it actually does return anything.
Hi Richard,
Thanks. The issue was to check for value in the property - kind of embarrasing. But my excuse is that is used to work before the upgrade.
/Jesper
Don't be embarrassed, as i only knew of the potential issue as it happened to me.
Glad everything is now working for you.
Will fallback to 0, if the item value is not a valid int, and this return NULL, which you check for later on in your code.
...also...
Saves you some typing :-)
... Also, maybe double check "headline"...
Hi Paul,
That's a good trick. Thanks.
/Jesper
is working on a reply...