Locate.ContentLoader() when using Episerver search



im looking at the Search example at the SDK developer guide : http://sdkbeta.episerver.com/SDK-html-Container/?path=/SdkDocuments/CMS/7/Knowledge%20Base/Developer%20Guide/Search/FullTextSearchCMSIntegration.htm&vppRoot=/SdkDocuments//CMS/7/Knowledge%20Base/Developer%20Guide/

When I am doing a copy/paste of the sample code for searching pages I get error on all the lines with Locate.<something> . I googled and found some code using : 

var context = new InitializationEngine();


this does however give me an object reference is null error.

What am I doing wrong ? 

Dec 17, 2012 14:14

The code I found is from this link: 



public void Initialize(EPiServer.Framework.Initialization.InitializationEngine context)
        var startPage = context.Locate.ContentLoader().Get<PageData>(PageReference.StartPage);

        //There should be a property on start page that sets the newsContainer page.
        var partialRouter = new NewsPartialRouter(new NewsContentStore(), startPage["NewsContainer"] as ContentReference);
        RouteTable.Routes.RegisterPartialRouter<NewsContainer, NewsContent>(partialRouter);

Dec 17, 2012 15:40

Solved it by fetching the ServiceLocationHelper :

 var serviceLocationHelper = ServiceLocator.Current.GetInstance<ServiceLocationHelper>();


Dec 18, 2012 9:22
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* 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.