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>();
}
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 ---
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
ISearchableTree issue
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:
Exception Details
System.InvalidOperationException: Type Cogworks.CustomInternalSearch.CustomSearchTree is already in the collection of types.
In my Application starting I have done:
However it still thinks its registered.
Any ideas? Appreciate this is 7.7 beta.
Regards
Ismail
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
I don't know what you mean by automatic registration?
Can you post your code for
CustomSearchTree
?Shannon,
I have updated Umbraco to 7.7.1 My code for CustomSearchTree looks like,
I am just returning empty list atm. Everything loads up however when i do a search in backoffice under content I get:
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.LazyManyObjectsResolverBase
2.AddValidAndNoDuplicate(List
1 list, Type type) at Umbraco.Core.ObjectResolution.LazyManyObjectsResolverBase2.<Initialize>b__17_0() at System.Lazy
1.CreateValue() at System.Lazy1.LazyInitValue() at Umbraco.Core.ObjectResolution.ManyObjectsResolverBase
2.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, IDictionary
2 arguments, CancellationToken cancellationToken) --- End of stack trace from previous location where exception was thrown ---Regards
Ismail
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 defaultContentTreeController
then you just remove theContentTreeController
is working on a reply...