Closed jessicah closed 3 years ago
I managed to workaround the issue by hoisting the RazorEngine
instance out of AddRazorLight()
, then adding the following:
services.AddSingleton(new RazorLightOptions());
services.AddSingleton(razorEngine.Handler.Compiler);
services.AddSingleton(razorEngine.Handler.FactoryProvider);
services.AddSingleton(razorEngine.Handler.Cache);
But it would be nice to not have to do this... although now I'm blocked on https://github.com/toddams/RazorLight/issues/365, so I don't know if it's fully resolved yet.
@jessicah I merged #365 fix this morning and will release this week. Thank you for your patience.
@jessicah Please update to 2.0.0-rc.1 package. Let me know if you run into any issues. Closing for now.
Describe the bug
services.AddRazorLight()
doesn't appear sufficient to register types needed for DI to work.To Reproduce Steps to reproduce the behavior:
Expected behavior RazorLight dependencies registered and able to run project.
Information (please complete the following information):
Additional context System.AggregateException: 'Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: RazorLight.IEngineHandler Lifetime: Singleton ImplementationType: RazorLight.EngineHandler': Unable to resolve service for type 'RazorLight.Compilation.IRazorTemplateCompiler' while attempting to activate 'RazorLight.EngineHandler'.)'