Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: The best
overloaded method match for 'umbraco.library.NiceUrl(int)' has some
invalid arguments
If I try it with a hard-coded int, it works as expected:
@umbraco.library.NiceUrl(1069)
And if I output this, it outputs the correct node ID (1069):
@CurrentPage.straplineLink
So, I have two questions:
How can I get this to work? (I've tried @umbraco.library.NiceUrl(int.Parse(CurrentPage.straplineLink)) but it doesn't work because it's not actually a string.
Why would this stop working due to a minor upgrade?
Thanks so much for this, Alex! I was indeed naive to think that there were no breaking changes.
I wrote the code some time back, so I guess I must be doing quite a few things that are now deprecated.
I also have this code later on. I have a list of items, some of which have an Image property set (for a media gallery item).
@var profileItems = CurrentPage.Children();
@foreach (var item in profileItems)
{
var isItemImagePresent = !string.IsNullOrWhiteSpace(item.profileItemImage);
var descriptionClass = isItemImagePresent ? "col-lg-10" : "col-lg-12";
// some more code
}
And this gives the very similar error:
Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: The best overloaded method match for 'string.IsNullOrWhiteSpace(string)' has some invalid arguments
Any idea what the best practice way of dealing with this is?
Note that I adapted this code from the "TXT" starter template. There, they used an image uploader for the image property. I allow images to be optional in news items. I later changed to use a Media Item instead (because I didn't like the way that an uploaded image is inaccessible after a user changes it and preferred images to be in the Media Section). Checking for string.IsNullOrWhiteSpace worked OK before 7.6.1.
Thanks so much Alex. I've now got the local version of my site working.
I'll test it properly before updating on Prod. Here's the site if you are interested: http://www.thesquad.org.uk
To answer your question - no, I don't have Property Value Converters. I've just Googled and wonder if I should. This site is just something I maintain in my spare time and I don't have a lot of time to do proper Umbraco stuff. But I think I will make time to check this out.
umbraco.library.NiceUrl not working after upgrade to 7.6.1
I've upgraded my installation from 7.5.13 to 7.6.1.
I'm surprised to see that this line now throws an error:
If I try it with a hard-coded int, it works as expected:
And if I output this, it outputs the correct node ID (1069):
So, I have two questions:
Hi Nick
Try this code:
Upgrade from 7.5.13 to 7.6.1 isn't minor, there are a lot of changes and few breaking changes - https://our.umbraco.org/documentation/getting-started/setup/upgrading/760-breaking-changes
Thanks,
Alex
Thanks so much for this, Alex! I was indeed naive to think that there were no breaking changes.
I wrote the code some time back, so I guess I must be doing quite a few things that are now deprecated.
I also have this code later on. I have a list of items, some of which have an Image property set (for a media gallery item).
And this gives the very similar error:
Any idea what the best practice way of dealing with this is?
Note that I adapted this code from the "TXT" starter template. There, they used an image uploader for the image property. I allow images to be optional in news items. I later changed to use a Media Item instead (because I didn't like the way that an uploaded image is inaccessible after a user changes it and preferred images to be in the Media Section). Checking for string.IsNullOrWhiteSpace worked OK before 7.6.1.
You are welcome, Nick. A lot of people realized that they need to change razor code little bit after latest upgrade.
Is "Property Value Converters" enabled in your solution?
It's important for fixing this issue if it's disabled this code should work:
Just add .ToString()
Thanks,
Alex
Thanks so much Alex. I've now got the local version of my site working.
I'll test it properly before updating on Prod. Here's the site if you are interested: http://www.thesquad.org.uk
To answer your question - no, I don't have Property Value Converters. I've just Googled and wonder if I should. This site is just something I maintain in my spare time and I don't have a lot of time to do proper Umbraco stuff. But I think I will make time to check this out.
is working on a reply...