Copied to clipboard

Flag this post as spam?

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


  • Tim 168 posts 372 karma points
    Aug 14, 2014 @ 00:04
    Tim
    0

    Adding ServiceStack reference breaks extension methods

    Whenever we install ServiceStack 3.9.x on a new v7 install we get the error message:

    'umbraco.MacroEngines.DynamicNodeList' does not contain a definition for 'Any'

    Removing ServiceStack.dll resolves the issue.

    Does anyone know why or how we can work around it?

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Aug 14, 2014 @ 00:26
    Jeavon Leopold
    0

    Hi Tim,

    Unfortunately there is no fix for the legacy DynamicNode/Razor Macro however it seems that the also affected MVC templates/Partial View Macros might be fixed in the v7.1.5 nightlies.

    Jeavon

  • Tim 168 posts 372 karma points
    Aug 14, 2014 @ 06:37
    Tim
    0

    Ok thanks Jeavon, any idea what's causing it? Happy to write a fix if someone is?

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Aug 14, 2014 @ 10:26
    Jeavon Leopold
    0

    Hi Tim,

    I have an unproven theory, this error seems either occur to .Any() or .Count() and happens to the now legacy DynamicNode and also to the DynamicPublishedContnt (CurrentPage) but not to IPublishedContent (Model.Content). So I think that these are extension methods and of course dynamics doesn't have extension methods, so there is a clever mechanism in Umbraco to support extension methods with dynamics (FindAndExecuteExtensionMethod). I think what happens is that some third party assemblies also have extension methods for .Count() or .Any() and for some reason the FindAndExecuteExtensionMethod finds these first but as they don't match the type we end up with this exception.

    However, as I said, it seems that DynamicPublishedContent may now not have this issue in v7.1.5....

    Jeavon

  • Stephen 767 posts 2273 karma points c-trib
    Aug 15, 2014 @ 10:08
    Stephen
    1

    Would surely need further testing to be sure, but that could be an explanation. Methods such as .Any() or .Count() "disappear" when the extension methods cannot be inferred either by the default runtime C# binder or by our own extended finder (which tries to find extension methods for dynamics). I think that our finder is not as smart as the C# binder, because infering the right method based upon parameters, etc. is a complex task (see the C# specs...) -- and potentially an expensive one.

    So to some extend... our dynamic support of extension methods prob. has flaws that would be complex & expensive to solve.

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Aug 15, 2014 @ 10:27
    Jeavon Leopold
    0

    Exactly, I have been trying to prove it. I can replicate easily on v7.1.4 but when I tried to do it with current v7.1.5 source I cannot replicate. I will have another attempt :-)

  • Tim 168 posts 372 karma points
    Aug 18, 2014 @ 07:56
    Tim
    0

    Cool, sounds like it's fixed which can only be a good thing

  • Bjørn Fridal 274 posts 784 karma points
    Aug 25, 2014 @ 10:49
    Bjørn Fridal
    0

    Hi,

    Just wanted to chime in, even though I am not using ServiceStack. It's the SolisSearch package that's causing my problem.

    I get the error: "Umbraco.Web.Models.DynamicPublishedContentList does not contain a definition for 'Any'" I tried upgrading to 7.15 but the error persists.

    Cheers
    Bjørn 

  • wolulcmit 357 posts 693 karma points
    Sep 02, 2014 @ 03:31
    wolulcmit
    0

    This also happens to me when adding the ImageResizer.Plugins.SimpleFilters.dll
    lose the ability to use Count()
    'Umbraco.Web.Models.DynamicPublishedContentList' does not contain a definition for 'Count'

    I'm running a fresh install of 7.1.6 assembly: 1.0.5350.25714

  • Bjarne Fyrstenborg 1280 posts 3990 karma points MVP 7x c-trib
    Sep 28, 2014 @ 16:28
    Bjarne Fyrstenborg
    0

    I have a Umbraco 7.1.6 installation, assembly: 1.0.5350.25714 where I use the .Any() method on a dynamic expression, where I get an exeption like:

    'Umbraco.Web.Models.DynamicPublishedContentList' does not contain a definition for 'Any' ... and a similar error if I use Count method.

    The code was working before, but after installing the Analytics package for Umbraco 7, it seems to conflict with the methods.

    /Bjarne

  • Carlos Mosqueda 240 posts 431 karma points
    Aug 03, 2015 @ 14:40
    Carlos Mosqueda
    0

    I have confirmed that ServiceStack.dll will break the .Any() and .Count();

    We have a project utilized some components of ServiceStack but did not require the base ServiceStack.dll to be in the references or the bin. So I took it out and the .Count() and .Any() in our navigation now works.

  • Stephen 767 posts 2273 karma points c-trib
    Mar 09, 2016 @ 10:40
Please Sign in or register to post replies

Write your reply to:

Draft