简体   繁体   中英

Umbraco razor macro DynamicPublishedContentList does not contain a definition for

My umbraco view has generated the following code for a macro that works fine:

@* Helper method to travers through all descendants *@
@helper Traverse(dynamic node)
{
    @* Update the level to reflect how deep you want the sitemap to go *@
    var maxLevelForSitemap = 5;

    @* Select visible children *@
    var selection = node.Children.Where("Visible").Where("Level <= " + maxLevelForSitemap);

    @* If any items are returned, render a list *@
    if (selection.Any())
    {
        <ul>
            @foreach (var page in selection)
            {
                <li class="level-@page.Level @(page.IsAncestorOrSelf(CurrentPage) ? "on" : null)">
                    @if (page.isNotNavigable == true)
                    {
                        <span>
                            <cite class="arrow"></cite>@page.Name
                        </span>
                    }
                    //if next line fails, add before the if below: page.HasProperty("pageRedirectTarget")
                    else if (page.HasValue("pageRedirectTarget"))
                    {
                        var redirectPage = Umbraco.Content(page.pageRedirectTarget);
                        <a href="@redirectPage.Url.Substring(0, redirectPage.Url.Length - 1)@page.pageRedirectComplement">
                            <cite class="arrow"></cite>@page.Name
                        </a>
                    }
                    else
                    {
                        <a href="@page.Url">
                            <cite class="arrow"></cite>@page.Name
                        </a>
                    }

                    @* Run the traverse helper again for any child pages *@
                    @Traverse(page)
                </li>
            }
        </ul>
    }
}

The problem happens when I added another dll (compiled in 3.5 framework) and the selection.Any() stop working, instead gives an error saying "does not contain a definition for Any()".

I know that dynamic doens't support extension methods but why does it work without me adding the reference and with it gives the error?

Can anyone help me?

thanks.

Not exactly an answer, but too long for a comment and hopefully it will help in your troubleshooting.
Check for the following .dlls in your bin directory and delete them if you don't need them for your project. Delete them one at a time and retest after each to see if you can nail it down.

EntityFramework.SqlServer.dll
WebGrease.dll (delete and update to latest)
DotNetOAuth.dll

This info came from the Umbraco forums and particularly the two posts linked below.

https://our.umbraco.org/forum/developers/razor/45308-umbracoMacroEnginesDynamicNodeList-does-not-contain-a-definition-for-Random

https://our.umbraco.org/forum/umbraco-7/using-umbraco-7/53022-UmbracoWebModelsDynamicPublishedContentList-does-not-contain-a-definition-for-Any

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM