New to Telerik Reporting? Download free 30-day trial

Resolving IMvcBuilder Errors When Hosting Telerik Reporting REST Service in ASP.NET Core

Environment

Product Reporting
Version 19.3.25.1119

Description

I encountered a build error when configuring the Telerik Reporting REST Service in ASP.NET Core with Minimal API.

Error Message

'IMvcBuilder' does not contain a definition for 'AddTelerikReporting' and no accessible extension method 'AddTelerikReporting' accepting a first argument of type 'IMvcBuilder' could be found (are you missing a using directive or an assembly reference?)

Solution

To resolve the error, ensure that the AddTelerikReporting method is applied to an IMvcBuilder object, as this extension method is defined for the IMvcBuilder interface. Follow these steps:

Option 1: Add an IMvcBuilder to the IServiceCollection

  1. Add services for pages to the specified IServiceCollection:

    var service = builder.Services.AddRazorPages();
    
  2. Add Newtonsoft.Json to the service:

    service.AddNewtonsoftJson();
    
  3. Define the reports path and add Telerik Reporting:

    var reportsPath = System.IO.Path.Combine(builder.Environment.ContentRootPath, "Reports");
    service.AddTelerikReporting("TelerikReportingRestServiceMinimalApi", reportsPath);
    

Option 2: Chain the extension methods

Alternatively, chain the AddRazorPages, AddNewtonsoftJson, and AddTelerikReporting methods directly:

builder.Services.AddMvc().AddNewtonsoftJson().AddTelerikReporting("TelerikReportingRestServiceMinimalApi", reportsPath);

Replace "TelerikReportingRestServiceMinimalApi" and the reports path with your specific configuration values.

See Also

In this article