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 1231 posts 2605 karma points
    1 week ago
    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 5978 posts 22689 karma points MVP 4x admin c-trib
    1 week ago
    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 5978 posts 22689 karma points MVP 4x admin c-trib
    1 week ago
    Alex Skrypnyk
    0

    Hi Amir,

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

    Alex

  • Amir Khan 1231 posts 2605 karma points
    1 week ago
    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 5978 posts 22689 karma points MVP 4x admin c-trib
    1 week ago
    Alex Skrypnyk
    0

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

  • Amir Khan 1231 posts 2605 karma points
    1 week ago
    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 5978 posts 22689 karma points MVP 4x admin c-trib
    1 week ago
    Alex Skrypnyk
    0

    You need to replace all places with this code:

    @if(Umbraco.AssignedContentItem.IsDescendantOrSelf(Umbraco.TypedContent(1831))) {
        @Html.Partial("HeroPattern")
    }
    
  • Amir Khan 1231 posts 2605 karma points
    1 week ago
    Amir Khan
    1

    Thank you!!

Please Sign in or register to post replies

Write your reply to:

Draft