November Happy Hour will be moved to Thursday December 5th.
AI OnAI Off
November Happy Hour will be moved to Thursday December 5th.
Hi,
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: https://world.episerver.com/blogs/Henrik-Fransas/Dates/2015/1/how-to-do-unit-testing-on-episerver-find/
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:
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:
EPiServer.CMS
EPiServer.CMS.UI
EPiServer.Find
EPiServer.Find.Framework
EPiServer.Framework
The ServiceLocation project was added through the EPiServer.CMS feed. Is there anything else we need?
Edit: This is Episerver Find 12.0.0.4448