Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • DS 21 posts 162 karma points
    Jul 20, 2016 @ 21:48
    DS
    0

    Model.Content - "The call is ambiguous..." error

    I am receiving the error:

    The call is ambiguous between the following methods or properties: 'Umbraco.Web.UmbracoHelper.Media(params int[])' and 'Umbraco.Web.UmbracoHelper.Media(params string[])'
    

    on this code:

    @{
         var hours = Model.Content.GetPropertyValue<IEnumerable<IPublishedContent>>("hoursList");
    
         foreach (var item in hours) // ERROR ON THIS LINE
         {
             if (item.HasValue("heading"))
             {
                <tr><td class="tablespace"></td></tr>
                <tr><td class="tablehead" colspan="2">@item.GetPropertyValue("heading")</td></tr>
                <tr><td class="tableleft">@item.GetPropertyValue("days")</td><td class="tableright">@item.GetPropertyValue("hours")</td></tr>
             }
             else
             {
                <tr><td class="tableleft">@item.GetPropertyValue("days")</td><td class="tableright">@item.GetPropertyValue("hours")</td></tr>
             }
          }
      }
    

    This block works perfectly on other document types. I am out of ideas as to what is going wrong in this specific instance.

    Any ideas?

    Thanks for the help!

  • David Peck 687 posts 1863 karma points c-trib
    Jul 22, 2016 @ 08:52
    David Peck
    0

    I'm not sure you've included the correct code. The error suggests that you're passing something into the media method which the compiler doesn't know if it is a string array or an int array. The code like look like Ùmbraco.Media(myVariable)`.

  • DS 21 posts 162 karma points
    Jul 22, 2016 @ 14:42
    DS
    0

    I'm not sure you've included the correct code. The error suggests that you're passing something into the media method which the compiler doesn't know if it is a string array or an int array. The code like look like Ùmbraco.Media(myVariable)`.

    Ya, this is why I was so confused by this error - the code I included is correct.

  • Paul Wright (suedeapple) 277 posts 704 karma points
    Jul 22, 2016 @ 09:03
    Paul Wright (suedeapple)
    0

    Check "hours" dosent contain anything NULL, or not of iPublishedContent, before you loop through it :-)

  • David Peck 687 posts 1863 karma points c-trib
    Jul 22, 2016 @ 09:30
    David Peck
    0

    Also, are you using the core property value converters or something else to allow you to do GetPropertyValue<IEnumerable<IPublishedContent>>. It sounds like an issue with the converter.

  • DS 21 posts 162 karma points
    Jul 22, 2016 @ 14:43
    DS
    0

    Also, are you using the core property value converters or something else to allow you to do GetPropertyValue<>

    I am not using the core property value converters package. I forgot to mention that "hoursList" is using Nested Content.

    I ended up deleting and re-creating the document type from scratch (and keeping the same template), and that has seemed to fix this problem. It's still a mystery what caused that error.

    Thank you for the brainstorming!

  • DS 21 posts 162 karma points
    Jul 26, 2016 @ 17:15
    DS
    0

    Ok, now I really don't get it. This problem is coming back on a completely separate and new template created from scratch, that also implements Nested Content. I just updated N.C. to the newest version as well.

    I am now getting the same "The call is ambiguous..." error on this code: (MasterLayout.cshtml has not been modified)

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @using Newtonsoft.Json.Linq;
    @using Newtonsoft.Json;
    @{
        Layout = "MasterLayout.cshtml";  //ERROR HERE
    }
    @section Head
    

    Stack trace:

    [RuntimeBinderException: The call is ambiguous between the following methods or properties: 'Umbraco.Web.UmbracoHelper.Media(params int[])' and 'Umbraco.Web.UmbracoHelper.Media(params string[])']
       CallSite.Target(Closure , CallSite , UmbracoHelper , Object ) +214
       System.Dynamic.UpdateDelegates.UpdateAndExecute2(CallSite site, T0 arg0, T1 arg1) +501
       ASP._Page_Views_ASCPage_cshtml.Execute() in c:\WEB\CSHP.net\Views\ASCPage.cshtml:5
       System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +253
       System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +148
       System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +107
       Umbraco.Core.Profiling.ProfilingView.Render(ViewContext viewContext, TextWriter writer) +232
       System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +375
       System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +90
       System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +833
       System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +833
       System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +81
       System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +186
       System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +38
       System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +29
       System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +65
       System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +53
       System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +36
       System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +38
       System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +44
       System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +65
       System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +38
       System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +399
       System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +137
    

    What am I missing or doing wrong? I have used this same code on multiple other templates successfully.

  • David Peck 687 posts 1863 karma points c-trib
    Jul 27, 2016 @ 08:10
    David Peck
    0

    I know that is line 5, but have you stepped through in the debugger to confirm the error happens on this line? Sometimes it is reported incorrectly.

    Does MasterLayout.cshtml inherit UmbracoTemplatePage as well?

Please Sign in or register to post replies

Write your reply to:

Draft