6

I have implemented the Search Module with my DXA 1.5 application using this script:

.\web-install.ps1 -distDestination "D:\Projects\Site" -searchProviderType AwsCloudSearchProvider

And I have configured my endpoints in CMS, now my Components are indexed at Amazon cloud.

But when I search content in search box using DXA SearchModule I'm getting null reference error

Object reference not set to an instance of an object.

After debugging the code, I identified that baseModelType is null in below method

public Type GetModelTypeFromSemanticMapping(Type baseModelType)

in SemanticSchema.cs file.

Detailed Error

ERROR - Object reference not set to an instance of an object. System.NullReferenceException: Object reference not set to an instance of an object. at Sdl.Web.Common.Mapping.SemanticSchema.<>c__DisplayClass25_0.b__0(Type t) in D:\Projects\MPSDXAmeyankTest\Sdl.Web.Common\Mapping\SemanticSchema.cs:line 120 at System.Linq.Enumerable.WhereEnumerableIterator1.MoveNext() at System.Linq.Buffer1..ctor(IEnumerable1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable1 source) at Sdl.Web.Common.Mapping.SemanticSchema.GetModelTypeFromSemanticMapping(Type baseModelType) in D:\Projects\MPSDXAmeyankTest\Sdl.Web.Common\Mapping\SemanticSchema.cs:line 120 at Sdl.Web.Tridion.Mapping.DefaultModelBuilder.BuildEntityModel(EntityModel& entityModel, IComponent component, Type baseModelType, Localization localization) at Sdl.Web.Tridion.Mapping.DefaultModelBuilder.BuildEntityModel(EntityModel& entityModel, IComponentPresentation cp, Localization localization)
at Sdl.Web.Tridion.Mapping.ModelBuilderPipeline.CreateEntityModel(IComponentPresentation cp, Localization localization) at Sdl.Web.Tridion.Mapping.DefaultModelBuilder.BuildPageModel(PageModel& pageModel, IPage page, IEnumerable`1 includes, Localization localization)

Any Guidelines will be appreciated.

1 Answer 1

3

That is weird. The baseModelType is obtained from the View Model Registry (the MVC data of the CT is resolved to a View Model Type), but is not expected to ever be null; in case the View Model Type cannot be resolved, an exception should be thrown.

I notice that you seem to be using a custom build of Sdl.Web.Common. Have you made any changes?

Since you are debugging already, you could backtrack to DefaultModelBuilder.BuildEntityModel where the (base) Model Type is determined and see where/how that becomes null.

10
  • Thanks for Reply i did not make any changes into dxa module after getting null reference error on view i debugged my code rather using compiled dlls. one Question do we need to add new rout for SI4T search controller. seems request in not going to SearchController
    – meyank
    Nov 11, 2016 at 14:51
  • No, you don't have to add a route; that is taken care of by the Search Module's AreaRegistration. The SearchController is an Entity Controller which is automatically invoked when the Search Results Page is requested. Nov 11, 2016 at 15:12
  • BTW: in order to debug, you don't have to do a custom build; you can also obtain the DXA PDBs from the DXA Distribution. Nov 11, 2016 at 15:14
  • under Search module area there is no AreaRegistration after installation of dxa search module shall i create manually ? or let me know any additional step to perform for search module to work
    – meyank
    Nov 11, 2016 at 15:21
  • No additional steps are needed. Just run web-install.ps1 like you mentioned (I assume that D:\Projects\Site is the root folder of your DXA Web App). The installer deploys the Search Module Views and Sdl.Web.Modules.Search.dll. The presence of that DLL in your DXA Web App bin Folder is enough to make it work. Nov 11, 2016 at 15:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.