'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?
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.
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!
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.
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"?
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.
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!
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
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.
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.
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'
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">
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.
'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?
Hi Micah,
Did you just upgrade from Umbraco 4?
This should fix your issues:
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
I would also recommend that you get your rootNode like the below instead of hard coding the node id
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:
This creates the error all by itself, with nothing else in the template. This also creates the error:
Thanks for your help so far. Any further suggestions or thoughts are much appreciated!
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.
Jeavon
Here's the error I get:
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"?
Yes, it does, can you check the web.config inside the /Views/ folder contains the following namespaces:
Yep, it does.
Really strange, how did you install Umbraco, manual or NuGet?
Also was this a fresh install or a upgrade?
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.
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....
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 :-)
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 :-)
I'm on 7.1.4 and have the same issue - I have to do ((IEnumerable<DynamicPublishedContent>) container).Count()
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!
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
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.
It seems like deleting these dll's does the trick...
Google.Apis.Auth.dll
Google.Apis.Auth.Mvc4.dll
Google.Apis.dll
My known list of assemblies that can cause dynamic extension methods such as Count, Any, First, Last to disappear are:
If you're interested in the cause, I have a unproven theory described here
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.
Hi Cathy,
i am facing same issue. Can you help me to solve it please
Hi Kamil,
I am experiencing the same problem as you.
How have you solved the problem pls?
Thank you.
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.
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.
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
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
andAny
where the main ones.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.
See http://issues.umbraco.org/issue/U4-6438
Hi,
I am facing this problem now. Anyone can suggest any solution please
is working on a reply...