The call is ambiguous between the following methods or properties: ‘Umbraco.Web.UmbracoHelper.Media

I was coding up a new template in the latest version of Umbraco v7 using Razor and discovered this error when trying to get a Media object from one of my properties of the current page.


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[])’

My property was a Media Picker type which I made the assumption it was given me a Integer Node Id to the specific media object.

I started out with the following code:

1
@Umbraco.Media(CurrentPage.ProfileImage).umbracoFile

This caused the error above, so by converting it to a string using the .ToString() method, this caused the compiler to ignore the error and use the correct UmbracoHelper method.

1
@Umbraco.Media(CurrentPage.portfolio5Image.ToString()).umbracoFile