title: Unable to resolve service for type Microsoft.AspNetCore.Mvc.Razor.IRazorViewEngine
body: <p>In my project that was <code>core 2.2</code> i have standard service for returning <code>Razor View</code> as string (i needed it to generate pdf in my client written in <code>WPF</code>): </p>
  
  <pre><code>public class RaportService : IRaportService
      {
          private readonly IProjectRepository projectRepository;
          private readonly IRazorViewEngine razorViewEngine;
          private readonly ITempDataProvider tempDataProvider;
          private readonly IServiceProvider serviceProvider;
  
          public RaportService(
              IProjectRepository projectRepository,
              IRazorViewEngine razorViewEngine,
              ITempDataProvider tempDataProvider,
              IServiceProvider serviceProvider)
          {
              this.projectRepository = projectRepository;
              this.razorViewEngine = razorViewEngine;
              this.tempDataProvider = tempDataProvider;
              this.serviceProvider = serviceProvider;
          }
  
          public async Task&lt;string&gt; GenerateProjectRaport(int projectId)
          {
              var project = await this.projectRepository.GetProjectWithTasksAsync(projectId)
                  ?? throw new EntityNotFoundException();
  
              var httpContext = new DefaultHttpContext { RequestServices = this.serviceProvider };
              var actionContext = new ActionContext(httpContext, new RouteData(), new ActionDescriptor());
  
              using (var stringWriter = new StringWriter())
              {
                  string viewPath = "~/wwwroot/RaportTemplate.cshtml";
  
                  var viewResult = this.razorViewEngine.GetView(viewPath, viewPath, false);
  
                  var viewDictionary = new ViewDataDictionary(new EmptyModelMetadataProvider(), new ModelStateDictionary())
                  {
                      Model = new RaportViewModel
                      {
                          Project = project,
                          ProjectTasks = project.Tasks.ToList(),
                          ProjectEndedTasks = project.EndedTasks.ToList(),
                      }
                  };
  
                  var viewContext = new ViewContext(
                      actionContext,
                      viewResult.View,
                      viewDictionary,
                      new TempDataDictionary(actionContext.HttpContext, this.tempDataProvider),
                      stringWriter,
                      new HtmlHelperOptions());
  
                  await viewResult.View.RenderAsync(viewContext);
                  return stringWriter.ToString();
              }
          }
      }
  </code></pre>
  
  <p>In <code>Core 2.2</code> everything work fine. When i updated my project to <code>Core 3.0</code> i get this error:</p>
  
  <pre><code>{
      "stackTrace":"   at MediatR.Internal.RequestHandlerBase.GetHandler[THandler](ServiceFactory factory)\r\n   
  at MediatR.Internal.RequestHandlerWrapperImpl`2.&lt;&gt;c__DisplayClass0_0.&lt;Handle&gt;g__Handler|0()\r\n   at MediatR.Pipeline.RequestPostProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)\r\n   
  at MediatR.Pipeline.RequestPreProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)\r\n  
   at TaskManager.Api.Controllers.RaportController.GetProjectRaport(Int32 projectId) in C:\\Users\\Michał\\Source\\Repos\\michasacuer\\TaskManager\\Src\\Web\\TaskManager.Api\\Controllers\\RaportController.cs:line 12\r\n   at lambda_method(Closure , Object )\r\n   
  at Microsoft.Extensions.Internal.ObjectMethodExecutorAwaitable.Awaiter.GetResult()\r\n   
  at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)\r\n   
  at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.&lt;InvokeActionMethodAsync&gt;g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)\r\n   
  at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.&lt;InvokeNextActionFilterAsync&gt;g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)\r\n  
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)\r\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State&amp; next, Scope&amp; scope, Object&amp; state, Boolean&amp; isCompleted)\r\n   
  at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n  
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.&lt;InvokeNextExceptionFilterAsync&gt;g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)",
      "message":"Error constructing handler for request of type MediatR.IRequestHandler`2[TaskManager.Application.Raport.Queries.GetProjectRaport.GetProjectRaportQuery,System.String]. Register your handlers with the container. See the samples in GitHub for examples."}
  
  </code></pre>
  
  <p>Even when i register that <code>IRazorViewEngine</code> interface and class in <code>Startup</code> it still throwing, thtat he need something that calls <code>IRazorPageFactoryProvider</code> but i dont know, what is an implementation of it. </p>
  
  <p>So how to get Razor View Engine working with <code>.NET Core 3.0</code>?</p>