Copied to clipboard

Flag this post as spam?

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


  • JJ 41 posts 83 karma points
    May 21, 2014 @ 17:06
    JJ
    0

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

    I've just upgraded from 7.0.3 to 7.1.3 and am getting this error on the first partial that loads on my homepage:

     

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

    Server Error in '/' Application.

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

     Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: 'Umbraco.Web.Models.DynamicPublishedContentList' does not contain a definition for 'Any'

    Source Error:

    Line 5:  }
    Line 6:  
    Line 7:  @if (root.StoreFocus.Any())
    Line 8:  {
    Line 9:      foreach (var childPage in root.StoreFocus.Random(1))


    Source File: d:\Work\TFS\RegentArcade-branch\Stardust\Views\Partials\StoreFocusPartial.cshtml    Line: 7

     

    (StoreFocus is a DocumentType by the way).

     

    The website worked fine before the upgrade. I followed the generic upgrade instructions and used NuGet, merging my web.config afterwards.

     

    Any advice please? I'd rather not go thru the pain of a downgrade.

     

    Cheers         

  • JJ 41 posts 83 karma points
    May 21, 2014 @ 17:19
    JJ
    1

    This is the source. Not a lot to it!

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @{
        var root = Umbraco.Content(ViewData["node"]);
    }
    @if (root.StoreFocus.Any())
    {
        foreach (var childPage in root.StoreFocus.Random(1))
        {
            //LAYOUT HTML HERE
        }
    }
  • Stephen 767 posts 2273 karma points c-trib
    May 22, 2014 @ 08:30
    Stephen
    0

    Last changes to DynamicPublishedContentList dates back from long time ago and was merged in 7.0 already... so it must come from somewhere else... will try to find time to look into it.

  • JJ 41 posts 83 karma points
    May 22, 2014 @ 16:21
    JJ
    0

    Any ideas where i can look please? I'm unable to continue developing as it is now...

  • Stephen 767 posts 2273 karma points c-trib
    May 22, 2014 @ 17:51
    Stephen
    0

    Following code runs fine on my 7.1.4 devt environment (with Test being a content type):

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @{
        var content = Umbraco.Content(1050);
    }
    @if (content.Test.Any())
    {
        <div>Yes</div>
    }

    And content.Test is a dynamic, underlying type being DynamicPublishedContentList.

    So... still trying to figure out what might be wrong. Sorry...

     

    Note that the following code fails:

    var list = new DynamicPublishedContentList();
    var any = list.Any();

    whereas the following code works:

    dynamic list = new DynamicPublishedContentList();
    var any = list.Any();

    Don't know if it helps...

  • Stephen 767 posts 2273 karma points c-trib
    May 22, 2014 @ 18:01
    Stephen
    0

    Could help debugging...

    Can you try to replace

    root.StoreFocus.Any()

    by

    Enumerable.Any(root.StoreFocus)

    and report the error you're seeing? DynamicPublishedContentList implements both IEnumerable<DynamicPublishedContent> and IEnumerable<IPublishedContent> and because of this, by default the compiler does not know if it should use Any<DynamicPublishedContent>() or Any<IPublishedContent>() and fails. Unless you're actually using a dynamic and then the runtime binder seems to be able to make the diff.

    Also could you try

    root.StoreFocus.Any<IPublishedContent>()

    ?

    Though I don't see why it would change btw 7.0 and 7.1...

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    May 22, 2014 @ 18:12
    Jeavon Leopold
    0

    Could it be that the id being passed into Umbraco.Content is null or for a node that has been deleted or is unpublished?

  • JJ 41 posts 83 karma points
    May 28, 2014 @ 18:28
    JJ
    0

    Thank-you for your patience, I've had computer issues.

    Result from using

    Enumerable.Any(root.StoreFocus)

    The type arguments for method 'System.Linq.Enumerable.Any<TSource>(System.Collections.Generic.IEnumerable<TSource>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.               Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

    Exception Details: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: The type arguments for method 'System.Linq.Enumerable.Any<TSource>(System.Collections.Generic.IEnumerable<TSource>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.

    Source Error:

    Line 6:  }
    Line 7:  
    Line 8: @if (Enumerable.Any(root.StoreFocus)) Line 9:  {
    

     

    Result from using

    root.StoreFocus.Any<IPublishedContent>()

    'Umbraco.Web.Models.DynamicPublishedContentList' does not contain a definition for 'Any'               Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

    Exception Details: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: 'Umbraco.Web.Models.DynamicPublishedContentList' does not contain a definition for 'Any'

    Source Error:

    Line 6:  }
    Line 7:  
    Line 8: @if (root.StoreFocus.Any<IPublishedContent>()) Line 9:  {
    
  • Stephen 767 posts 2273 karma points c-trib
    May 28, 2014 @ 18:36
    Stephen
    0

    Damn. Last one: Enumerable.Any<IPublishedContent>(root.StoreFocus)

    ?

  • JJ 41 posts 83 karma points
    May 28, 2014 @ 18:46
    JJ
    0

    slight progress!

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

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: 'Umbraco.Web.Models.DynamicPublishedContentList' does not contain a definition for 'Random'

    Source Error:

    Line 8:  @if (Enumerable.Any<IPublishedContent>(root.StoreFocus))
    Line 9:  {
    Line 10: foreach (var childPage in root.StoreFocus.Random(1)) Line 11:     {
    Line 12:         var retailer = Umbraco.Content(childPage.retailer);


    Source File: d:\home\site\wwwroot\Views\Partials\StoreFocusPartial.cshtml    Line: 10

    FYI, i'm back on 7.0.2 now having rolled back my source control and still getting these issues...

  • Stephen 767 posts 2273 karma points c-trib
    May 28, 2014 @ 18:49
    Stephen
    0

    Aha. So 7.0.2 also has the issue, so it's not a "new" issue with 7.1 - correct?

    I think I'm starting to understand where it's coming from...

  • JJ 41 posts 83 karma points
    May 28, 2014 @ 18:52
    JJ
    0

    It first occured straight after my upgrade to 7.1.x, but seems it's showing same issue in 7.0.2 now...

     

    confused.com!!!

  • JJ 41 posts 83 karma points
    May 28, 2014 @ 18:57
    JJ
    0

    It first occured straight after my upgrade to 7.1.x, but seems it's showing same issue in 7.0.2 now...

     

    confused.com!!!

  • JJ 41 posts 83 karma points
    May 29, 2014 @ 10:22
    JJ
    0

    Stephen, where did you go?!

  • Stephen 767 posts 2273 karma points c-trib
    Jun 02, 2014 @ 21:03
    Stephen
    0

    Still there, got caught into other things, will try to get back to you asap.

  • JJ 41 posts 83 karma points
    Jun 04, 2014 @ 18:53
    JJ
    0

    I'm really struggling here. got 2 sites down due to this. One is a fresh install which i've just deployed.

  • Stephen 767 posts 2273 karma points c-trib
    Jun 28, 2014 @ 13:00
    Stephen
    0

    General issue with DynamicPublishedContentList extension methods.

    To be discussed at: http://issues.umbraco.org/issue/U4-5084

  • Paul LaForge 1 post 22 karma points
    Dec 14, 2014 @ 18:32
    Paul LaForge
    1

    I'm not sure where the best place is to post this, but I was able to "solve" an error tied to GetGridHtml() and "does not contain a definition for Any()" in 7.2.0.  I realize it may not solve everyone's experience, but perhaps, it will move the community forward.

    I am new to Umbraco (we're talking seriously new!).  I've been playing with it a few days when suddenly, I was getting the errors it appears some are running into. One positive was that I was running two versions: one was pristine and one was the one I was messing with--and messed up.  Note:  since I was new, this was not an upgrade scenario

    I did a full dependency comparison and hunted for clues based on the limited posts regarding these errors.

    Ultimately, the answer lies in the /bin directory. When I ported over files, I brought over another EntityFramework dl:  EntityFramework.SqlServer.dll.  When that .dll is present in the bin directory, I get the errors above.  When I remove it, all is well and things work perfectly.

    Hope this helps!  

  • Andrew Frost 3 posts 73 karma points
    Aug 02, 2016 @ 03:47
    Andrew Frost
    0

    Thanks for that.

    I had introduced a new project to my solution that had Entity Framework in it, and was a different version, which caused this error for me. Once I removed the dll for the new project from the bin folder this problem went away.

  • Ismael 71 posts 354 karma points
    Dec 15, 2014 @ 23:08
    Ismael
    0

     EntityFramework.SqlServer.dll was also the cause of this issue on my 6.1.6 installation - I think it came from EF 6 which I had installed for a custom section, before rolling back to EF 5.

     


  • Simon steed 374 posts 686 karma points
    Dec 16, 2014 @ 15:56
    Simon steed
    0

    I've just upgraded a 7.1.8 build to 7.2.0 then 7.2.1 and now get this problem - looking into it but no entityframework dlls in my site

    Si

  • keilo 568 posts 1023 karma points
    Apr 29, 2015 @ 20:27
    keilo
    0

    have you guys figured out a solution to this? Im hitting the same

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

    on version 7.1.8 assembly: 1.0.5394.16131 install.Cant upgrade to later versions for quick testing and on the lookout for a quick-fix - if any...

    The error being thrown at normally used-to-work ok code, cant figure how to fix it.

    Line 7: @if (CurrentPage.Ancestors().Any())

    any ideas? I have the entire site re-published and the ancestors of that currentpage re-published, yet no joy..

  • Adrian Ursu 20 posts 51 karma points
    Aug 25, 2015 @ 16:18
    Adrian Ursu
    0

    Hello guys,

    I have also encountered this error. In my case it was after I have moved from SQL Server Compact to SQL Server 2008. Not sure if these 2 are related in any way. Before the change, everything worked normally. I have also upgraded to the latest version hoping it will solve it. Now I am running 7.2.8. The back-end is ok but the front end is broken Any ideea?

    Thanks,

    Adrian

  • Dimitris Lampsakis 4 posts 74 karma points
    Sep 27, 2015 @ 22:53
    Dimitris Lampsakis
    0

    Have the same problem. whenever i add the Kendo.Mvc.dll i get the same error. i will try to find the older version of the Kendo.Mvc.dll because I'm thinking it might be a different MVC version.

    by the way let me know if anyone has seen a nice guide how to implement Umbraco 7 with kendo controls

    Update: The problem solved with the right Kendo.Mvc version

  • Chuck Kirklen 36 posts 184 karma points
    Nov 27, 2015 @ 20:32
    Chuck Kirklen
    0

    Same here - started with a 7.2.6 installation with CE on local machine; moved it to Windows 2012 Server and SQL 2012. After copying back down to local machine, am now getting this when trying to run against local SQL 2012.

    This is the Adrian Ursu kind of issue - appeared in front end after CE-to-SQL conversion.

    Rest of the site works, but when trying to call partial view macros, i'm getting this.

    Any insight appreciated.

  • Chuck Kirklen 36 posts 184 karma points
    Nov 28, 2015 @ 01:47
    Chuck Kirklen
    1

    Solved (in my case)! I had installed the Export SQL Server Compact package to export my local CE database to SQL Server on the production site.

    Successfully uploaded to production and the production site worked just fine. Content was added to production for a month or so.

    Local (CE) site continued to work fine, as well, on my local machine with very little content. The minute I backed up the production DB and restored it to full SQL Server on the local box and pointed my local Umbraco site to it, the errors started.

    Only by UNINSTALLING the Export SQL Server Compact package did the errors go away.

    Lesson learned: you'll need to uninstall Export SQL Server Compact package as soon as you stop using CE and want to use the SQL Server DB the package helps you create.

  • Tessa 20 posts 72 karma points
    Feb 08, 2016 @ 22:50
    Tessa
    1

    I had the same exact error running in version 7.3.7, and I solved it by creating a variable first thanks to this Stack Overflow suggestion.

    Old Broken Code:

    if(CurrentPage.Children.Any()){
        //Do something
    }
    

    Updated Working Code:

    Umbraco.Web.Models.DynamicPublishedContentList subpages = CurrentPage.Children;
    if(subpages.Any()){
        //Do something
    }
    

    Hopefully that helps anyone else that comes across this problem!

  • Steven Baker 7 posts 77 karma points
    Feb 20, 2016 @ 08:59
    Steven Baker
    0

    Hello guys,

    I just upgraded from 7.2 to 7.4.1 - big leap, I know. Everything was looking good until I received this error.

    I had installed NEST 2.0.2. and it was causing the issue with Umbraco.Web.Models.DynamicPublishedContentList. Still not quite sure what the issue is but NEST 2 employs some of the c# 6 'goodness' and this might be causing the issue with 'dynamic'.

    If I find out anymore I'll post back.

    Steve

  • Mac McDell 73 posts 148 karma points
    Apr 13, 2016 @ 20:57
    Mac McDell
    0

    FWIW.. I came across this thread after trying out the CoreValueConverters project at https://our.umbraco.org/projects/developer-tools/umbraco-core-property-value-converters It implemented fine but I wasn't interested in continuing with it so I used Nuget to uninstall the package. That's when I got the same error. I ended up doing the following to get back on track.

    1. Deleted bin folder and rebuilt. (no luck)
    2. Deleted asp.net temp files--started getting new error ''using Our.Umbraco.PropertyConverters.Models;''
    3. did a search for PropertyConverters and found a namespace reference still sitting in the views/web.config. Deleted the namespace and site came back online.

    I noticed also I still had a namespace reference to

    <add namespace="Umbraco.Web.PublishedContentModels" />
    

    so I left that there.

  • Andrew Frost 3 posts 73 karma points
    Aug 02, 2016 @ 04:31
    Andrew Frost
    0

    I had the same problem, but for me this seemed to be something to do with conflicting versions of log4net.

  • Jan Raets 1 post 71 karma points
    Sep 19, 2016 @ 00:05
    Jan Raets
    0

    For those running into the error after upgrading from SQL Server Compact to MSSQL, ensure you uninstall the Export SQL Server Compact package!

  • Hong 66 posts 228 karma points
    Jun 10, 2017 @ 21:49
    Hong
    0

    I want to echo the resolution of Chuck Kirklen. I too had this problem after using Export SQL Server Compact package, and fixed by uninstalling the package per Chuck's tip.

Please Sign in or register to post replies

Write your reply to:

Draft