muso31/Helixbase

Context is null error

Closed this issue · 3 comments

I'm trying to implement same in Sitecore 10 with glass mapper pre-release

I get the below error on setting sitecore service in ORM project
public void Configure(IServiceCollection serviceCollection)
{
serviceCollection.AddTransient(provider => new SitecoreService(Sitecore.Context.Database));
serviceCollection.AddScoped<IRequestContext, RequestContext>();
serviceCollection.AddScoped<IMvcContext, MvcContext>();
serviceCollection.AddScoped<IGlassHtml, GlassHtml>();
}

Error:
[NullReferenceException: Context is null]
Glass.Mapper.AbstractService..ctor(Context glassContext) +425
Glass.Mapper.Sc.SitecoreService..ctor(Database database, Context context) +23

Sorry @abhishek-v-github just to be clear - is this an issue with Helix Base or a separate solution?

Its a separate solution with exact code copied.

Sorry for the confusion, its not an issue, missed adding some configurations.