Copied to clipboard

Flag this post as spam?

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


  • Micah Redding 7 posts 50 karma points
    Apr 10, 2014 @ 21:43
    Micah Redding
    0

    'Umbraco.Web.Models.DynamicPublishedContentList' does not contain a definition for 'Count'

    The code below used to work perfectly, but has stopped working. Basically, it loads the root node, and then attempts to loop through the children of that node. I use an if statement to know whether there are any children (and thus whether I should continue to drill down or not). The "if" statement calls "Count" on the children. As I said, this did work up until yesterday.

    Now it gives me the error: 'Umbraco.Web.Models.DynamicPublishedContentList' does not contain a definition for 'Count'

    Incidentally, calling "@CurrentPage.NiceUrl()" also stopped working. Any ideas?

        <nav class="mobile-nav-primary mobile-menu">
        <ul>
          @{
            var siteroot = @Umbraco.Content(1103);
          }
          @foreach(var page in @siteroot.Children()) {
            if (page.Children().Count() > 0) {
              <li class="has-sub-menu">
                <a href="@page.Url()">@page.name</a>
                <ul class="sub-menu">
                  @foreach(var subpage in page.Children()) {
                    if(page.Children().Count() < 1) {
                      <li><a href="@subpage.Url()">@subpage.name</a></li>
                    } else {
                      <li>
                        <a href="@subpage.Url()">@subpage.name</a>
                        <ul>
                          @foreach(var subsubpage in subpage.Children()) {
                            <li><a href="@subsubpage.Url()">@subsubpage.name</a></li>
                          }
                        </ul>
                      </li>
                    }
                  }
                </ul>
              </li>
            } else {
              <li><a href="@page.Url()">@page.name</a></li>
            }
          }
        </ul>
      </nav>
    
  • Jeavon Leopold 3005 posts 13193 karma points MVP 7x admin c-trib
    Apr 10, 2014 @ 22:03
    Jeavon Leopold
    0

    Hi Micah,

    Did you just upgrade from Umbraco 4?

    This should fix your issues:

    <nav class="mobile-nav-primary mobile-menu">
        <ul>
            @{
                var siteroot = Umbraco.Content(1103);
            }
            @foreach (var page in siteroot.Children)
            {
                if (page.Children.Count() > 0)
                {
                    <li class="has-sub-menu">
                        <a href="@page.Url()">@page.Name</a>
                        <ul class="sub-menu">
                           @foreach (var subpage in page.Children)
                            {
                                if (page.Children.Count() < 1)
                                {
                                    <li><a href="@subpage.Url">@subpage.Name</a></li>
                                }
                                else
                                {
                                    <li>
                                        <a href="@subpage.Url">@subpage.Name</a>
                                        <ul>
                                            @foreach (var subsubpage in subpage.Children)
                                            {
                                                <li><a href="@subsubpage.Url">@subsubpage.Name</a></li>
                                            }
                                        </ul>
                                    </li>
                                }
                            }
                        </ul>
                    </li>
                }
                else
                {
                    <li><a href="@page.Url">@page.Name</a></li>
                }
            }
        </ul>
    </nav>  
    

    You main issues were the @ within the code blocks, this is not valid in Razor v2 which was introduced with Umbraco v6 but was ok with Razor v1 in Umbraco v4.

    Jeavon

  • Jeavon Leopold 3005 posts 13193 karma points MVP 7x admin c-trib
    Apr 10, 2014 @ 22:04
    Jeavon Leopold
    0

    I would also recommend that you get your rootNode like the below instead of hard coding the node id

        @{
            var siteroot = CurrentPage.AncestorOrSelf(1);
        }
    
  • Micah Redding 7 posts 50 karma points
    Apr 11, 2014 @ 08:31
    Micah Redding
    0

    Hi Jeavon,

    Thanks very much for the help. This is a new site, built on Umbraco 7 from the group up. I'm new to Umbraco, and I'm sure I've read documentation for the wrong version somewhere along the way.

    At first I thought your solution worked, because the errors stopped. But then I realized that they only stopped because it was never getting to the "Count" directive at all. "siteroot.Children" apparently returns a DynamiCPublishedContentList, but there is nothing in it, and Count does not work on it.

    This is odd, because this precise approach had been working. I'm not sure what changed.

    In the interest of simplifying the problem, I have reproduced this exact error using a Partial that only has the following code:

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @{
      var c = Umbraco.Content(1103).Children.Count();
    }
    

    This creates the error all by itself, with nothing else in the template. This also creates the error:

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @{
      var c = CurrentPage.Children.Count();
    }
    

    Thanks for your help so far. Any further suggestions or thoughts are much appreciated!

  • Jeavon Leopold 3005 posts 13193 karma points MVP 7x admin c-trib
    Apr 11, 2014 @ 12:25
    Jeavon Leopold
    0

    Hi Micah,

    What error do you get? I cannot recreate your issue with the starter kit in Umbraco v7.1.1, you can see below I'm debugging to see what is in "c" and it is counting "11" when rendering the homepage.

    enter image description here

    Jeavon

  • Micah Redding 7 posts 50 karma points
    Apr 11, 2014 @ 15:30
    Micah Redding
    0

    Here's the error I get:

    enter image description here

    It feels like something in the infrastructure of the site has gone missing somehow. Can you tell me if CurrentPage.Children gives you a "DynamicPublishedContentList"?

  • Jeavon Leopold 3005 posts 13193 karma points MVP 7x admin c-trib
    Apr 11, 2014 @ 15:41
    Jeavon Leopold
    0

    Yes, it does, can you check the web.config inside the /Views/ folder contains the following namespaces:

      <namespaces>
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Routing" />
        <add namespace="Umbraco.Web" />
        <add namespace="Umbraco.Core" />
        <add namespace="Umbraco.Core.Models" />
        <add namespace="Umbraco.Web.Mvc" />
        <add namespace="Microsoft.Web.Helpers" />
        <add namespace="umbraco" />
        <add namespace="Examine" />
      </namespaces>
    
  • Micah Redding 7 posts 50 karma points
    Apr 11, 2014 @ 16:18
    Micah Redding
    0

    Yep, it does.

  • Jeavon Leopold 3005 posts 13193 karma points MVP 7x admin c-trib
    Apr 11, 2014 @ 17:25
    Jeavon Leopold
    0

    Really strange, how did you install Umbraco, manual or NuGet?

    Also was this a fresh install or a upgrade?

  • Micah Redding 7 posts 50 karma points
    Apr 13, 2014 @ 00:39
    Micah Redding
    0

    I've installed it several different ways, through Webmatrix, and then manually. This is a manual install, currently running on IIS, with a SQL Express database.

    This was a fresh install. And was working up until a few days ago.

  • Jeavon Leopold 3005 posts 13193 karma points MVP 7x admin c-trib
    Apr 13, 2014 @ 00:48
    Jeavon Leopold
    0

    It really is strange, are you running v7.1.1?

    One other thought for you, does this error occur on every node you execute it on? Maybe even try on a page without any children....

  • Jeavon Leopold 3005 posts 13193 karma points MVP 7x admin c-trib
    Apr 13, 2014 @ 01:05
    Jeavon Leopold
    0

    I think the only way we are going to solve this is if you can send me a zip of all your site files and a backup of your database. DM me on Twitter :-)

  • Jeavon Leopold 3005 posts 13193 karma points MVP 7x admin c-trib
    Apr 13, 2014 @ 11:34
    Jeavon Leopold
    0

    Ok, got it, I was able to replicate in Umbraco v7.0.4 , however this issue is fixed in Umbraco v7.1.1, so all you need to do is upgrade :-)

  • Shane Marsden 12 posts 74 karma points
    Jul 30, 2014 @ 17:07
    Shane Marsden
    0

    I'm on 7.1.4 and have the same issue - I have to do ((IEnumerable<DynamicPublishedContent>) container).Count()

  • Martin Bellemare 1 post 21 karma points
    Aug 07, 2014 @ 21:19
    Martin Bellemare
    0

    I'm on 7.1.4 and had the same issue - I had Google Analytics package installed and stopped working. I uninstalled the package and everything is fine now. Go figure!

  • Casey Neehouse 1339 posts 483 karma points MVP 2x admin
    Aug 13, 2014 @ 14:56
    Casey Neehouse
    0

    Does the GA package install the SASS bits for ClientDependency? Specifically, IronRuby dll?  If so, IronRuby seems to interfere with the extension methods in Umbraco

  • Kamil 7 posts 68 karma points
    Aug 14, 2014 @ 17:50
    Kamil
    0

    Hi,

    I have the same problem with my website. I'm using umbraco 7.0.2 assembly: 1.0.5133.26607. I am developing the website locally on my machine using Visual Studio.

    The website has lots of subpages, secondary and tertiary menu items, 2 navigation menus, breadcrumbs, additional left-hand side menu, lists of subpages, newsletter. Every single one of those elements use the methods like .Count(), Any(), .First(), Last() to find the related dynamic subpages, either children or parents.
    The problem is everything runs great on localhost, but as soon as I publish it to the server, all those methods stop working and produce the above error message.

     

  • Tom 116 posts 442 karma points
    Aug 15, 2014 @ 10:10
    Tom
    0

    It seems like deleting these dll's does the trick...

    Google.Apis.Auth.dll

    Google.Apis.Auth.Mvc4.dll

    Google.Apis.dll

  • Jeavon Leopold 3005 posts 13193 karma points MVP 7x admin c-trib
    Aug 15, 2014 @ 10:24
    Jeavon Leopold
    0

    My known list of assemblies that can cause dynamic extension methods such as Count, Any, First, Last to disappear are:

    • Google.Apis.Auth.dll
    • Google.Apis.Auth.Mvc4.dll
    • Google.Apis.dll
    • ServiceStack.dll
    • WebGrease.dll (pre v1.5.2)
    • DotNetOAuth.dll

    If you're interested in the cause, I have a unproven theory described here

  • Cathy Pank 21 posts 41 karma points
    Sep 17, 2014 @ 22:14
    Cathy Pank
    0

    I was also having this issue on an Umbraco 7 site, but only on one server, not on the other which had been installed seperately but contained the same packages. One was a clean install and the other an upgrade.

    The site which was not working was Umbraco 7 -Umbraco version 7.1.6 assembly: 1.0.5350.25714.

    The site which was working was 7.0.1.

    Going through the dlls one by one, the fix for me was to replace ClientDependency.Core.dll on the broke site from 1.7.1.2 to  the version from the other site 1.7.0.4.

    Now the site seems to work absoloutly fine. I was also able to fix a different brand new nuget setup project using this method.

  • abin 2 posts 72 karma points
    Jun 25, 2018 @ 10:17
    abin
    0

    Hi Cathy,

    i am facing same issue. Can you help me to solve it please

  • Simon 692 posts 1067 karma points
    Mar 06, 2015 @ 11:42
    Simon
    0

    Hi Kamil,

    I am experiencing the same problem as you.

    How have you solved the problem pls?

    Thank you.

  • Simon 692 posts 1067 karma points
    Mar 24, 2015 @ 16:54
    Simon
    0

    Hi Cathy,

    I am having the same problem as you but the same sites. On one server it is working fine, but on another server, it is not working, showing such errors like cannot invoke a non delegate type, and 'Umbraco.Web.Models.DynamicPublishedContentList' does not contain a definition for 'Any'

    What might be the solution pls?

    thank you.

  • Damian Chambers 20 posts 84 karma points
    Apr 16, 2015 @ 16:36
    Damian Chambers
    0

    I recently updated from Umbraco 7.0 to 7.2. Now I am getting this error: 

     

    'Umbraco.Web.Models.DynamicPublishedContentList' does not contain a definition for 'Count'

     

    on some pages.

     

    Need help.

  • Damian Chambers 20 posts 84 karma points
    Apr 16, 2015 @ 16:37
    Damian Chambers
    0

    Getting this error in the backend, whenever I attempt to access a document type:

     

    Server Error in '/' Application.


    Compilation Error

    Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 

    Compiler Error Message: CS1061: 'ASP.umbraco_controls_contenttypecontrolnew_ascx' does not contain a definition for 'dgTabs_ItemDataBound' and no extension method 'dgTabs_ItemDataBound' accepting a first argument of type 'ASP.umbraco_controls_contenttypecontrolnew_ascx' could be found (are you missing a using directive or an assembly reference?)

    Source Error:

     
    Line 25:     
    Line 26:   <cc2:Pane ID="Pane1" runat="server" Width="216" Height="80">
    Line 27: <asp:DataGrid ID="dgTabs" Width="100%" runat="server" CellPadding="2" HeaderStyle-CssClass="propertyHeader" Line 28:       ItemStyle-CssClass="propertyContent" GridLines="None" OnItemCommand="dgTabs_ItemCommand" OnItemDataBound="dgTabs_ItemDataBound" OnPreRender="dgTabs_PreRender"
    Line 29:       HeaderStyle-Font-Bold="True" AutoGenerateColumns="False" CssClass="tabs-table">


    Source File: E:\HostingSpaces\centralj\centralja.org\wwwroot\umbraco\controls\ContentTypeControlNew.ascx    Line: 27 


    Show Detailed Compiler Output:


    Show Complete Compilation Source:
  • Rob Scott 41 posts 94 karma points
    Jun 29, 2015 @ 02:17
    Rob Scott
    0

    I know this is an old post, but still ongoing. I think that A LOT of people are experiencing the same issue, which is:

    Cannot use LINQ with Dynamic Objects, whether it be DynamicPublishedContentLists, and in my situation, DynamicNodes. It seems that whatever DLL(s) are create these objects, and have the extension methods are broke.

    In my case, I installed uCommerce v6.6 about 3 weeks ago. All fine and dandy, everything working, installed demo store, blah blah.

    Low and behold, a lot of my partial views stopped working for no reason, haven't touched them in months. Anything that had to do w/ dynamic objects and LINQ was broke.

    Count and Any where the main ones.

    // examples 
    Model.Ancestors().Any()
    page.Children.Any()
    
    var products = CurrentPage.Descendants("Product").Where("popularProduct == true").ToList();
    if (products.Count() > 0)  ........
    

    I've even re-downloaded the v7.1.4 Umbraco binary files (the version that I'm using), and re-added them to to bin folder. No go.

    Does anyone have the absolute answer to this? Why does LINQ extension methods not work w/ dynamic objects, as 10 people in here had the same issue.

  • Stephen 767 posts 2265 karma points c-trib
    Mar 09, 2016 @ 10:39
  • abin 2 posts 72 karma points
    Jun 25, 2018 @ 09:45
    abin
    0

    Hi,

    I am facing this problem now. Anyone can suggest any solution please

Please Sign in or register to post replies

Write your reply to:

Draft