The call is ambiguous between the following methods or properties...
The call is ambiguous between the following methods or properties: 'Umbraco.Web.UmbracoHelper.Media(params int[])' and 'Umbraco.Web.UmbracoHelper.Media(params string[])'
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: The call is ambiguous between the following methods or properties: 'Umbraco.Web.UmbracoHelper.Media(params int[])' and 'Umbraco.Web.UmbracoHelper.Media(params string[])'
Source Error on line 38
Line 36:
Line 37: var Slide = Umbraco.Content(slideId);
Line 38: var ImagePath = Umbraco.Media(Slide.image).Url;
Line 39: var Text = Umbraco.Content(Slide.text);
Line 40: var Link = Umbraco.Content(Slide.linkTo);
Not sure what the problem is, but the problem with dynamics (rather than typed) is you're never sure on the type of your properties. Using typed will mean the code gets less confused, e.g.:
Line 37: var Slide = Umbraco.TypedContent(slideId);
Line 38: var ImagePath = Umbraco.Media(Slide.GetPropertyValue<int>("image")).Url;
Line 39: var Text = Umbraco.Content(Slide.GetPropertyValue<int>("text"));
Line 40: var Link = Umbraco.Content(Slide..GetPropertyValue<int>("linkTo"));
That wasn't the problem I guess – it didn't help :-/
But THX for your time!
It says:
The call is ambiguous between the following methods or properties: 'Umbraco.Web.UmbracoHelper.Media(params int[])' and 'Umbraco.Web.UmbracoHelper.Media(params string[])'
And it happened out of the blue – suddenly it won't get the image path. It has no problem looping all added "slides"... but an error occurs on line 38 – imagePath...
Heres the full code...
<div id="carousel" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators hidden-xs">
@{
var slidesArr = CurrentPage.slides.ToString().Split(new string[] { "," }, StringSplitOptions.None);
int countIt = 0;
foreach(var slideId in slidesArr){
if (countIt == 0) {
<li data-target="#carousel" data-slide-to="0" class="active"></li>
} else {
<li data-target="#carousel" data-slide-to="@countIt"></li>
}
countIt++;
}
}
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
@{
int countItem = 1;
foreach(var slideId in slidesArr){
var Slide = Umbraco.Content(slideId);
var ImagePath = Umbraco.Media(Slide.image).Url;
var Text = Umbraco.Content(Slide.text);
var Link = Umbraco.Content(Slide.linkTo);
var LinkUrl = Link.Url;
if (countItem == 1) {
<div class="item active"><a href="@LinkUrl">
<img src="@ImagePath" alt="...">
<div class="carousel-caption">
@Slide1.text
</div></a>
</div>
} else {
<div class="item"><a href="@LinkUrl">
<img src="@ImagePath" alt="...">
<div class="carousel-caption">
@Slide1.text
</div></a>
</div>
}
countItem++;
}
}
</div>
I'm a total newbie - so Ill need a little help on the Null test :-) And it seems to be null – but it runs though all 4 slides – just empty where text, imagepath and linkto should have been...
var Slide = Umbraco.Content(slideId);
var ImagePath = Umbraco.Media(Slide.image.ToString()).Url;
var Text = Umbraco.Content(Slide.text.ToString());
var Link = Umbraco.Content(Slide.linkTo.ToString());
This doesn't give an error, and it runs through alle slides. But there are no content in @ImagePath, @LinkUrl, @Slide.text
Hi Jon. The problem is that the UmbracoHelper method Umbraco.Media() method excepts both an integer parameter representation of the id, as well as a string representation. You are passing in a dynamic object, therefor the call gets ambingous.
Either parse it as an integer with Umbraco.Media(Int32.Parse(Slide.image)) or ToString() it like Umbraco.Media(Slide.image.ToString()). Off corse you need to check before the it has a value with
I've added the ToString() – and now there's no error... But it doesn't even reach the Id of the Slides... I've added Languages earlier today...could that have made any changes to this?
You need to confirm what type slideId actually is. If you output @slideId.GetType() then you're looking for this to be a string or an int for your code to work.
Depending on your installed packages and code, it might return something different.
It seems that even if I've publish all slides and slideholder with the common "Save & Publish" button, I still have to right click and click "publish" and select these to....
» Publish Frontpage Sliders and all its subpages
» Include unpublished child pages
Hi Jon. Is it possible that you might have forgotten to publish the Slide after selecting the SliteItems? Easy mistake. Always double check if the nodes are published when you are having problems.
If you are sure however that you had published, keep an extra eye out if this happens again, then it might be a bug.
The call is ambiguous between the following methods or properties...
The call is ambiguous between the following methods or properties: 'Umbraco.Web.UmbracoHelper.Media(params int[])' and 'Umbraco.Web.UmbracoHelper.Media(params string[])'
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: The call is ambiguous between the following methods or properties: 'Umbraco.Web.UmbracoHelper.Media(params int[])' and 'Umbraco.Web.UmbracoHelper.Media(params string[])'
Source Error on line 38
Not sure what the problem is, but the problem with dynamics (rather than typed) is you're never sure on the type of your properties. Using typed will mean the code gets less confused, e.g.:
Hi David
That wasn't the problem I guess – it didn't help :-/ But THX for your time!
It says: The call is ambiguous between the following methods or properties: 'Umbraco.Web.UmbracoHelper.Media(params int[])' and 'Umbraco.Web.UmbracoHelper.Media(params string[])'
And it happened out of the blue – suddenly it won't get the image path. It has no problem looping all added "slides"... but an error occurs on line 38 – imagePath...
Heres the full code...
Is that a typo on the
var Slide1 = Umbraco.Content(slideId);
Shouldn't that be Slide?
Ooh, that was just an typo from a test... :-)
In that case, have you tried:
I would recommend doing a null check against the media before returning the Url as well, as otherwise you will get a YSOD if this fails.
I'm a total newbie - so Ill need a little help on the Null test :-) And it seems to be null – but it runs though all 4 slides – just empty where text, imagepath and linkto should have been...
I've just tried to change it to:
This doesn't give an error, and it runs through alle slides. But there are no content in @ImagePath, @LinkUrl, @Slide.text
Hi Jon. The problem is that the UmbracoHelper method Umbraco.Media() method excepts both an integer parameter representation of the id, as well as a string representation. You are passing in a dynamic object, therefor the call gets ambingous.
Either parse it as an integer with Umbraco.Media(Int32.Parse(Slide.image)) or ToString() it like Umbraco.Media(Slide.image.ToString()). Off corse you need to check before the it has a value with
if(Slide.HasValue("image"))
Best of luck to you!! Take care!
Hi Dennis
I've added the ToString() – and now there's no error... But it doesn't even reach the Id of the Slides... I've added Languages earlier today...could that have made any changes to this?
I've worked my way back to see where it fails. It seems that Slide never gets defined. I am not able to print @Slide – but Im able to print @SlideId.
So my guess is that its in this line somethings wrong?
You need to confirm what type slideId actually is. If you output
@slideId.GetType()
then you're looking for this to be a string or an int for your code to work.Depending on your installed packages and code, it might return something different.
I've just found the problem...
It seems that even if I've publish all slides and slideholder with the common "Save & Publish" button, I still have to right click and click "publish" and select these to....
» Publish Frontpage Sliders and all its subpages » Include unpublished child pages
Isn't that a bug?
Hi Jon. Is it possible that you might have forgotten to publish the Slide after selecting the SliteItems? Easy mistake. Always double check if the nodes are published when you are having problems.
If you are sure however that you had published, keep an extra eye out if this happens again, then it might be a bug.
Glad it worked out for you anyway!
Take care!!
is working on a reply...