Resolving "No report instance" Error
Environment
Product | Progress® Telerik® Reporting |
Version | 18.3.24.1112 |
Description
After upgrading a project to use the Progress® Telerik® Reporting 2024 Q4 (18.3.24.1112) version of the Telerik Reporting assemblies, the reports fail to load with a console error stating No report instance
was found.
Cause
The problem is most commonly caused by custom JsonSerializerSettings specified in the AddNewtonsoftJson
method which interferes with the serialization process required for the Telerik Reporting to function properly.
Solution
To resolve the No report instance
error, consider one of the following approaches:
Using Default JsonSerializerSettings
Update the AddNewtonsoftJson method in the Program.cs
file of the project to use the default JsonSerializerSettings:
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddNewtonsoftJson();
Creating an Action Filter for custom JsonSerializerSettings
If using the default serializer settings is not an option due to application requirements, create an ActionFilter to customize the JsonSerializerSettings for the reports controller:
-
Implement the
JsonConfigFilterAttribute
ActionFilter:using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Filters; using Newtonsoft.Json; using Newtonsoft.Json.Serialization; using Microsoft.AspNetCore.Mvc.Formatters; using System.Buffers; using Microsoft.Extensions.Options; public class JsonConfigFilterAttribute : ActionFilterAttribute { public override void OnResultExecuting(ResultExecutingContext context) { if (context.Result is ObjectResult objectResult) { var serializerSettings = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Include, DateTimeZoneHandling = DateTimeZoneHandling.Unspecified, ContractResolver = new CamelCasePropertyNamesContractResolver() }; var jsonOutputFormatter = new NewtonsoftJsonOutputFormatter( serializerSettings, ArrayPool<char>.Shared, new MvcOptions { }, new MvcNewtonsoftJsonOptions() ); objectResult.Formatters.Add(jsonOutputFormatter); } base.OnResultExecuting(context); } }
-
Annotate the
ReportsController
with the newly createdJsonConfigFilter
attribute:[Route("api/[controller]")] [ApiController] [JsonConfigFilter] public class ReportsController : ReportsControllerBase { public ReportsController(IReportServiceConfiguration reportServiceConfiguration) : base(reportServiceConfiguration) { } }