I am having a weird issue, hoping you all have some pointers. I am using Umbraco 4.11.10 and trying to fulfill a requirement to display 1 random quote from a collection of quotes. The really puzzling thing is that this exact code works on a different site using the same version of Umbraco. The line causing the issue is...
var item = Model.NodeById(1150).Children.Random();
If I remove .Random and output the @item variable, it is a DynamicNodeList. And I know DynamicNodeList supports Random, but the error from the error log says the following
"'umbraco.MacroEngines.DynamicNodeList' does not contain a definition for 'Random'"
The only difference between the site where it works, and the site where it doesnt is that the site that works was setup up using the Web Platform Installer, and the one that doesn't work was setup in Visual Studio using Package Manager, so I have to assume it's a dll version or something, but so far I've had no luck.
Yes odd indeed. The site was created as a 4.11.10 site, no upgrades. The fact that this code works in another 4.11.10 instance makes me suspect some different dll's were used between the two types of installers, but I even went to the site where this code works, copied the Umbraco.MacroEngines.dll, the System.Web.WebPages.Razor.dll and the System.Web.Razor.dll over to the site where it is not working, but no luck there either.
Anton - I don't know if this would help you specifically, but there were some issues with 6.1.4 and 6.1.5 was released very quickly afterwards. Upgrading may help
The original install was on version 6(All worked fine).I then upgraded to 6.1.4 when the error started happening.
I did do an upgrade to 6.1.5 but to no avail.
As I mentioned everything works fine on my dev box and development server but I don't have access to the staging and production server of my client(ftp only).
Something changed with the umbraco build between 6 and 6.1.4 which breaks on my clients servers.
The only problem with that snippet is the @ before Model,
Should be:
@inherits umbraco.MacroEngines.DynamicNodeContext
@using Umbraco.Core.Services;
@{
var selection = Model.AncestorOrSelf().Descendants("Department");
}
@*Determine if there are any nodes in the selection, then render list *@
@if(selection.Any()){
}
I keep getting 'umbraco.MacroEngines.DynamicNodeList' does not contain a definition for 'Any' whenever we install DotNetOAuth or WebGrease. As soon as the dlls are removed from the bin folder everything works fine.
Although we have a "fix" it's not really a fix because we need the libraries.
Have you got either of those (or another custom library) installed?
Tim ,absolutely, there is something bad in WebGrease that can do this, however I have found that the current version v1.5.2 doesn't have the same issue have you tried the latest version?
Jeavon, I got to the bottom of it as we're using Bundling on other sites, in my case it was that we hadn't uploaded Antlr3.Runtime.dll but I've not got to the bottom of the issue with the OAuth stuff
Razor fails using Children.Random
Hello all,
I am having a weird issue, hoping you all have some pointers. I am using Umbraco 4.11.10 and trying to fulfill a requirement to display 1 random quote from a collection of quotes. The really puzzling thing is that this exact code works on a different site using the same version of Umbraco. The line causing the issue is...
If I remove .Random and output the @item variable, it is a DynamicNodeList. And I know DynamicNodeList supports Random, but the error from the error log says the following
"'umbraco.MacroEngines.DynamicNodeList' does not contain a definition for 'Random'"
The only difference between the site where it works, and the site where it doesnt is that the site that works was setup up using the Web Platform Installer, and the one that doesn't work was setup in Visual Studio using Package Manager, so I have to assume it's a dll version or something, but so far I've had no luck.
Any ideas?
Thanks -Roger
Hi Roger,
Have you tried to at an at before the Model like this:
Maybe this little change wil solve your issue with the random method.
/Dennis
Thanks Dennis,
Here is the entire macro with your update, but no change.
And the entire error from the log.
BTW..even if I remove the div and everything inside the div, it still fails with the same error
Okay,
DonĀ“t know if this can help you on the right way
http://our.umbraco.org/forum/developers/razor/35398-display-random-node
/Dennis
Hi Roger,
Seems odd, I just tried this sample and it seems fine....
Has your site always been v4.11.10 or has it been upgraded from an older version?
Perhaps check the assembly version on umbraco.MacroEngines.dll, on my v4.11.10 site I have 1.0.4926.14936
Jeavon
Hi Jeavon,
Yes odd indeed. The site was created as a 4.11.10 site, no upgrades. The fact that this code works in another 4.11.10 instance makes me suspect some different dll's were used between the two types of installers, but I even went to the site where this code works, copied the Umbraco.MacroEngines.dll, the System.Web.WebPages.Razor.dll and the System.Web.Razor.dll over to the site where it is not working, but no luck there either.
-Roger
Hi Roger,
I would try copying a complete clean v4.11.10 over the top (backup first) and then use source control to see if there were any differences.
I haven't used it but I think uDiff would also do the compare for you.
Jeavon
Hi I'm receiving a similar error Umbraco v6.1.4
'umbraco.MacroEngines.DynamicNodeList' does not contain a definition for 'Any'
It works fine on my dev environment but not in my staging environment.
I did a clean copy of all the DLL's but I still get the same error
Anton - I don't know if this would help you specifically, but there were some issues with 6.1.4 and 6.1.5 was released very quickly afterwards. Upgrading may help
Hi Steve
Thanks. I'm really at a loss here.
The original install was on version 6(All worked fine).I then upgraded to 6.1.4 when the error started happening.
I did do an upgrade to 6.1.5 but to no avail.
As I mentioned everything works fine on my dev box and development server but I don't have access to the staging and production server of my client(ftp only).
Something changed with the umbraco build between 6 and 6.1.4 which breaks on my clients servers.
At the moment is is a guessing game.
Any Ideas welcome.
Try remove the @ from before Model.. i've had issues with that between environments before
Here's some code I have that does very similar to what you're trying, maybe that'll help.
Sorry I just read your original post properly, you don't have the @ symbol on there. Anyway maybe my code will help.
Have you tried to redeploy the site to the server? Maybe under a separate IIS website?
Not sure what else to suggest... sounds like a bit of a doozy. Good luck
Hi Anton,
What version of v6 did it work fine for you pre upgrade? I would like to try to reproduce, also what is the code that fails for you?
Thanks,
Jeavon
Jeavon
I upgraded from 6.00 which worked fine.
As I mentioned on my servers which is set up properly all is working well, but on these numbnuts' servers it ain't.
I have no access to them so I'm shooting in the dark.
The code:
@inherits umbraco.MacroEngines.DynamicNodeContext
@using Umbraco.Core.Services;
@{
}
@*Determine if there are any nodes in the selection, then render list *@
@if(selection.Any()){ <----YSOD
Hi Anton,
The only problem with that snippet is the @ before Model,
Should be:
I keep getting 'umbraco.MacroEngines.DynamicNodeList' does not contain a definition for 'Any' whenever we install DotNetOAuth or WebGrease. As soon as the dlls are removed from the bin folder everything works fine.
Although we have a "fix" it's not really a fix because we need the libraries.
Have you got either of those (or another custom library) installed?
Tim ,absolutely, there is something bad in WebGrease that can do this, however I have found that the current version v1.5.2 doesn't have the same issue have you tried the latest version?
Jeavon, I got to the bottom of it as we're using Bundling on other sites, in my case it was that we hadn't uploaded Antlr3.Runtime.dll but I've not got to the bottom of the issue with the OAuth stuff
is working on a reply...