Copied to clipboard

Flag this post as spam?

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


  • Amir Khan 1282 posts 2739 karma points
    Apr 28, 2021 @ 17:21
    Amir Khan
    0

    Constant log error for IsDescendantOrSelf

    Getting this log error repeatedly on a 7,10.4 site. Any ideas what might be causing it?

    ERROR Umbraco.Core.Dynamics.DynamicInstanceHelper - An error occurred finding and executing extension method "IsDescendantOrSelf" for type "Umbraco.Web.Models.DynamicPublishedContent". Types searched for extension methods were Umbraco.Web.Models.DynamicPublishedContent. System.MissingMethodException: Method 'Umbraco.Web.Models.DynamicPublishedContent.IsDescendantOrSelf' not found. at Umbraco.Core.Dynamics.DynamicInstanceHelper.FindAndExecuteExtensionMethod[T](IRuntimeCacheProvider runtimeCache, T thisObject, Object[] args, String name, IEnumerable`1 findMethodsOnTypes)

  • Alex Skrypnyk 6132 posts 23951 karma points MVP 7x admin c-trib
    Apr 28, 2021 @ 21:35
    Alex Skrypnyk
    0

    Hi Amir

    The problem is that you are calling extension methods on a dynamic. Please, find the place where it's used and rewrite it to strongly typed.

    Thanks,

    Alex

  • Alex Skrypnyk 6132 posts 23951 karma points MVP 7x admin c-trib
    Apr 30, 2021 @ 17:38
    Alex Skrypnyk
    0

    Hi Amir,

    Can you share the code? and maybe you have some questions?

    Alex

  • Amir Khan 1282 posts 2739 karma points
    Apr 30, 2021 @ 17:43
    Amir Khan
    0

    Hey Alex, the issue is there are dynamics being used in various places and the error log doesn't say which partial is throwing the error so I'm not sure where to begin with debugging.

  • Alex Skrypnyk 6132 posts 23951 karma points MVP 7x admin c-trib
    Apr 30, 2021 @ 17:46
    Alex Skrypnyk
    0

    Can you use Visual Studio? Just do a search over the code for "IsDescendantOrSelf" method.

  • Amir Khan 1282 posts 2739 karma points
    Apr 30, 2021 @ 17:49
    Amir Khan
    0

    There's lots of it. Here's an example to switch a partial based on the parent page. We have to do this for various reasons on this particular site. Is there a better way?

    @if(CurrentPage.IsDescendantOrSelf(Umbraco.Content(1831))) {
       @Html.Partial("HeroPattern")
    }
    
  • Alex Skrypnyk 6132 posts 23951 karma points MVP 7x admin c-trib
    Apr 30, 2021 @ 17:58
    Alex Skrypnyk
    0

    You need to replace all places with this code:

    @if(Umbraco.AssignedContentItem.IsDescendantOrSelf(Umbraco.TypedContent(1831))) {
        @Html.Partial("HeroPattern")
    }
    
  • Amir Khan 1282 posts 2739 karma points
    Apr 30, 2021 @ 17:59
    Amir Khan
    1

    Thank you!!

Please Sign in or register to post replies

Write your reply to:

Draft