}
This was working nicely, until I upgraded to the latest umbraco release, now when I try running the site I get the following error:
'Umbraco.Core.Models.PublishedContent.PublishedContentEnumerable' does not contain a definition for 'Split'
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: 'Umbraco.Core.Models.PublishedContent.PublishedContentEnumerable' does not contain a definition for 'Split'
Source Error:
Line 2: @if (CurrentPage.HasValue("hpImageLinks"))
Line 3: {
Line 4: var hpImageLinksImagesList = CurrentPage.hpImageLinks.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
Line 5: var hpImageLinksImagesCollection = Umbraco.Media(hpImageLinksImagesList);
Line 6: foreach (var hpItem in hpImageLinksImagesCollection)
Unfortunately, this means that I cannot upgrade this site until I have a solution, any help would be gratefully received. Thanks
Thanks Alex, I tried that but now I'm getting:
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS1061: 'object' does not contain a definition for 'Split' and no extension method 'Split' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)
Source Error:
Line 3: @if (Umbraco.AssignedContentItem.HasValue("hpImageLinks"))
Line 4: {
Line 5: var hpImageLinksImagesList = Umbraco.AssignedContentItem.GetPropertyValue("hpImageLinks").Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
Line 6: var hpImageLinksImagesCollection = Umbraco.TypedMedia(hpImageLinksImagesList);
Line 7:
I will see if I can fathom what is happening from reading through the information on the link you very kindly gave me. Thanks for your help. I do find it quite wearying when this sort of thing happens, I was just about to go live with this site, and split string seems like such a basic function that I could get to work time and again in any other form of code no matter what the upgrade status of the application is. But I am still quite new to umbraco, so .....
new issue since upgrading to 7.6.1
I was successfully displaying a block of 8 images on the main page of a site using media picker and the following script:
@inherits Umbraco.Web.Macros.PartialViewMacroPage @if (CurrentPage.HasValue("hpImageLinks")) { var hpImageLinksImagesList = CurrentPage.hpImageLinks.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); var hpImageLinksImagesCollection = Umbraco.Media(hpImageLinksImagesList); foreach (var hpItem in hpImageLinksImagesCollection) { var itemLink = hpItem.GetPropertyValue("link");
} This was working nicely, until I upgraded to the latest umbraco release, now when I try running the site I get the following error:
'Umbraco.Core.Models.PublishedContent.PublishedContentEnumerable' does not contain a definition for 'Split' Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: 'Umbraco.Core.Models.PublishedContent.PublishedContentEnumerable' does not contain a definition for 'Split'
Source Error:
Line 2: @if (CurrentPage.HasValue("hpImageLinks")) Line 3: { Line 4: var hpImageLinksImagesList = CurrentPage.hpImageLinks.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); Line 5: var hpImageLinksImagesCollection = Umbraco.Media(hpImageLinksImagesList); Line 6: foreach (var hpItem in hpImageLinksImagesCollection)
Unfortunately, this means that I cannot upgrade this site until I have a solution, any help would be gratefully received. Thanks
Hi Karen
Umbraco changed GetPropertyValue method little bit, read more about breaking changes - https://our.umbraco.org/documentation/getting-started/setup/upgrading/760-breaking-changes#property-value-converters-u4-7318
Your code should work if you will use these lines:
Hope it will help
Alex
Thanks Alex, I tried that but now I'm getting: Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS1061: 'object' does not contain a definition for 'Split' and no extension method 'Split' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)
Source Error:
Line 3: @if (Umbraco.AssignedContentItem.HasValue("hpImageLinks")) Line 4: { Line 5: var hpImageLinksImagesList = Umbraco.AssignedContentItem.GetPropertyValue("hpImageLinks").Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); Line 6: var hpImageLinksImagesCollection = Umbraco.TypedMedia(hpImageLinksImagesList); Line 7:
I will see if I can fathom what is happening from reading through the information on the link you very kindly gave me. Thanks for your help. I do find it quite wearying when this sort of thing happens, I was just about to go live with this site, and split string seems like such a basic function that I could get to work time and again in any other form of code no matter what the upgrade status of the application is. But I am still quite new to umbraco, so .....
Karen, try these lines:
Alex you are a MEGASTAR. Thank you so much! I really appreciate your help and yes that now works fine! (phew)
You are welcome, I'm really happy that we found out what was the problem.
Have a nice day!
Alex
Me too! and you have a fantastic day yourself X
is working on a reply...