Copied to clipboard

Flag this post as spam?

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


  • Alex Wojtowicz 1 post 71 karma points
    Feb 14, 2023 @ 16:51
    Alex Wojtowicz
    0

    Custom tree implementation returning "Sequence contains no matching element" error v11.1.0

    Hi,

    I'm attempting to implement a custom tree for the backoffice v.11.1.0. I have copied the implementation for the "Favorite Things" tree straight from the documentation: https://docs.umbraco.com/umbraco-cms/extending/section-trees/trees

    Mainly, I care about the implementation of this TreeController:

    [Tree("settings", "favouriteThingsAlias", TreeTitle = "Favourite Things 
    Name", TreeGroup="favouritesGroup", SortOrder=5)]
    public class FavouriteThingsTreeController : TreeController
    { }
    

    This should create a new tree in the "Settings" section under a new group and populate with placeholder nodes. When I boot up the site and view the "Settings" section, this error is encountered:

    enter image description here

    The exception is being thrown in this request: https://localhost:44371/umbraco/backoffice/umbracotrees/applicationtree/GetApplicationTrees?application=settings&tree=&use=main

    {"ExceptionMessage":"Sequence contains no matching element","ExceptionType":"System.InvalidOperationException, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","StackTrace":"   at System.Linq.ThrowHelper.ThrowNoMatchException()\r\n   at Umbraco.Cms.Web.BackOffice.Trees.ApplicationTreeController.GetApiControllerProxy(Type controllerType, String action, FormCollection querystring)\r\n   at Umbraco.Cms.Web.BackOffice.Trees.ApplicationTreeController.GetRootNode(Tree tree, FormCollection querystring)\r\n   at Umbraco.Cms.Web.BackOffice.Trees.ApplicationTreeController.TryGetRootNode(Tree tree, FormCollection querystring)\r\n   at Umbraco.Cms.Web.BackOffice.Trees.ApplicationTreeController.GetApplicationTrees(String application, String tree, FormCollection queryStrings, TreeUse use)\r\n   at lambda_method262(Closure, Object)\r\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)\r\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)\r\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)\r\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)\r\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)\r\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()\r\n--- End of stack trace from previous location ---\r\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)"}
    

    From what I can tell, it appears that the exception is being thrown in this code here: https://github.com/umbraco/Umbraco-CMS/blob/contrib/src/Umbraco.Web.BackOffice/Trees/ApplicationTreeController.cs

    ControllerActionDescriptor? actionDescriptor = _actionDescriptorCollectionProvider.ActionDescriptors.Items
        .Cast<ControllerActionDescriptor>()
        .First(x =>
            x.ControllerName.Equals(controllerName) &&
            x.ActionName == action);
    

    The .First() method invocation cannot return an object that matches the specified conditions.

    Is there some other registration step that I am missing, or could there be an issue with the Umbraco code?

    Thanks,

  • Nathan Rhodehouse 2 posts 72 karma points notactivated
    Jun 01, 2023 @ 15:06
    Nathan Rhodehouse
    0

    I had a similar issue. Discovered that I needed to add a directory "App_Plugins" to the project.

Please Sign in or register to post replies

Write your reply to:

Draft