SmartSearch access causing strange ObjectFactory type error

Jason Lindsay asked on September 25, 2019 16:28

I am creating a custom module for CMS that creates a custom page index using code. Following the documentation on creating a SmartSearch, I created code creates a new SmartSearchInfo object.

var newIndex = new SearchIndexInfo();

looking inside the object exposes that most of the object properties are returning NotSupportedException errors. Upon executing the line where this index is registered, an error returns:

SearchIndexInfoProvider.SetSearchIndexInfo(newIndex);

[ObjectFactory.CurrentObjectFactory]: Implementation for type 'IDataClass' was not found, make sure that assembly with implementation is present in the bin folder of your application. If the assembly is present, the implementation must be registered by call to ObjectFactory

Correct Answer

Jason Lindsay answered on September 25, 2019 20:15

With the help of Kentico support, I chased down my problem. The code I am referencing was placed in the constructor, and before Kentico is finished its app initialization. I moved my code down to the OnInit() method instead, and the custom module started working fine. Takeaway here is don't put your code in the constructor. :)

0 votesVote for this answer Unmark Correct answer

   Please, sign in to be able to submit a new answer.