Copied to clipboard

Flag this post as spam?

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


  • Ismail Mayat 4511 posts 10090 karma points MVP 2x admin c-trib
    Sep 08, 2017 @ 11:01
    Ismail Mayat
    0

    So I am playing with ISearchableTree in v7.7 beta. Following code here

    When I try and do a backoffice search with my new searcher I get the following error:

    Type Cogworks.CustomInternalSearch.CustomSearchTree is already in the collection of types.

    Exception Details

    System.InvalidOperationException: Type Cogworks.CustomInternalSearch.CustomSearchTree is already in the collection of types.

    In my Application starting I have done:

    SearchableTreeResolver.Current.RemoveType<ContentTreeController>();
    
            //add your custom one - this would need to return the same tree alias as the content one
            if (!SearchableTreeResolver.Current.ContainsType<CustomSearchTree>())
            {
                SearchableTreeResolver.Current.AddType<CustomSearchTree>();
            }
    

    However it still thinks its registered.

    Any ideas? Appreciate this is 7.7 beta.

    Regards

    Ismail

  • Ismail Mayat 4511 posts 10090 karma points MVP 2x admin c-trib
    Sep 08, 2017 @ 13:14
    Ismail Mayat
    0

    Update to this so I have taken out the Application starting code so its registering automagically but I still get the same error.

    Regards

    Ismail

  • Shannon Deminick 1524 posts 5269 karma points MVP 2x
    Sep 21, 2017 @ 05:35
    Shannon Deminick
    0

    I don't know what you mean by automatic registration?

    Can you post your code for CustomSearchTree ?

  • Ismail Mayat 4511 posts 10090 karma points MVP 2x admin c-trib
    Sep 29, 2017 @ 09:23
    Ismail Mayat
    0

    Shannon,

    I have updated Umbraco to 7.7.1 My code for CustomSearchTree looks like,

            public IEnumerable<SearchResultItem> Search(string query, int pageSize, long pageIndex, out long totalFound, string searchFrom = null)
        {
            totalFound = 0;
            return Enumerable.Empty<SearchResultItem>();
        }
    

    I am just returning empty list atm. Everything loads up however when i do a search in backoffice under content I get:

    An error occured

    Type Cogworks.CustomInternalSearch.CustomSearchTree is already in the collection of types.

    Exception Details

    System.InvalidOperationException: Type Cogworks.CustomInternalSearch.CustomSearchTree is already in the collection of types. Stacktrace

    at Umbraco.Core.ObjectResolution.LazyManyObjectsResolverBase2.AddValidAndNoDuplicate(List1 list, Type type) at Umbraco.Core.ObjectResolution.LazyManyObjectsResolverBase2.<Initialize>b__17_0() at System.Lazy1.CreateValue() at System.Lazy1.LazyInitValue() at Umbraco.Core.ObjectResolution.ManyObjectsResolverBase2.CreateInstances() at Umbraco.Core.ObjectResolution.ManyObjectsResolverBase2.get_Values() at Umbraco.Web.Search.SearchableTreeResolver.GetSearchableTrees() at Umbraco.Web.Editors.EntityController.SearchAll(String query) at lambda_method(Closure , Object , Object[] ) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary2 arguments, CancellationToken cancellationToken) --- End of stack trace from previous location where exception was thrown ---

    Regards

    Ismail

  • Shannon Deminick 1524 posts 5269 karma points MVP 2x
    Oct 09, 2017 @ 23:20
    Shannon Deminick
    1

    Ahh, i didn't realize that we scan for ISearchableTree instances. So all you need to do is modify the resolver to remove the duplicates.

    Your ISearchableTree instance will automatically be registered and if you are using the same alias as the default ContentTreeController then you just remove the ContentTreeController

     SearchableTreeResolver.Current.RemoveType<ContentTreeController>();
    
Please Sign in or register to post replies

Write your reply to:

Draft