Try our conversational search powered by Generative AI!

Activation Error on IStatisticTagsHelper


Hi, I have a standalone project in a .NET solution that gets compiled to a DLL and used in another solution. The regular Find functionality works great, however, in trying to add statistics tracking we have run in to an issue with the Service Locator apparently not being able to resolve the IStatisticTagsHelper interface when we add .Track() to our search query. We are trying to avoid adding too many references, so most likely that is the issue here, but perhaps not.

The code: 

            var results = query.Skip((iPage - 1) * m_iRecordsPerPage)
                               .Select(r => new SearchResultItem { Title = r.SearchTitle, Url = r.SearchHitUrl, MetaData = r.SearchMetaData })

The exception: 

An exception of type 'EPiServer.ServiceLocation.ActivationException' occurred in EPiServer.Framework.dll but was not handled in user code

Additional information: Activation error occurred while trying to get instance of type IStatisticTagsHelper, key ""

at EPiServer.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceType, String key)
at EPiServer.ServiceLocation.ServiceLocatorImplBase.GetInstance[TService]()
at EPiServer.Find.Framework.Statistics.TrackableSearchExtensions.AddDefaultTags(IEnumerable`1 tags)
at EPiServer.Find.Framework.Statistics.TrackableSearchExtensions.Track[TSource](ISearch`1 search, IEnumerable`1 tags)
at EPiServer.Find.Framework.Statistics.TrackableSearchExtensions.Track[TSource](ISearch`1 search)
at AAP.Website.Search.Data.EPiServerFind.SearchClient.GetSearchResultWithPagination(String sSearchTxt, Int32 iPage, Boolean bPageOnly, FindResults oFindResults, Int32 iRecordLimitForFilters, Boolean bShowFacets, Boolean bSiteSpecific, String sSpecificSite) in C:\w\AAP\AAP.Website.Search\AAP.Website.Search.Data\EPiServerFind\SearchClient.cs:line 172
at AAP.Website.Search.Controllers.SearchController.<>c__DisplayClass6_1.b__0() in C:\w\AAP\AAP.Website.Search\AAP.Website.Search\Controllers\SearchController.cs:line 105
at System.Threading.Tasks.Task.InnerInvoke()

We have added the following Episerver nuget packages to this project:






The ServiceLocation project was added through the EPiServer.CMS feed. Is there anything else we need?

Edit: This is Episerver Find

Edited, Jul 11, 2017 0:29


How did you setup your dependency injection container (IoC - in this case Structuremap) in your standalone project? If you go to `EPiServer.Find.Framework.Statistics.StatisticTagsHelper` type, you will see that it has attribute `[ServiceConfiguration]`. Meaning that EPiServer does automatic IoC setup by scanning and registering known types or registrations to the container. Later on EPiServer is using Service Locator to get instance of that interface. You can lookup "unit test epsierver" in your favorite search engine for some hints how to setup IoC container and make ServiceLocator happy. For instance:

Jul 24, 2017 1:17
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.