When following How to Host Reports in .NET CORE 5 can't resolve ConfigurationHelper

1 Answer 84 Views
.NET Core
Kenneth
Top achievements
Rank 2
Iron
Kenneth asked on 28 May 2022, 08:23 PM

Following the instructions on the the web site and the video for building a ASP ,NET CORE 5 app to host Telerik reporting using VS 2022.

When I paste in the block:

services.TryAddSingleton<IReportServiceConfiguration>(sp =>
            new ReportServiceConfiguration
            {
                ReportingEngineConfiguration =  ConfigurationHelper.ResolveConfiguration(sp.GetService<IWebHostEnvironment>()),
                HostAppId = "Net5RestServiceWithCors",
                Storage = new FileStorage(),
                ReportSourceResolver = new UriReportSourceResolver(
                    System.IO.Path.Combine(sp.GetService<IWebHostEnvironment>().ContentRootPath, "Reports"))
            });

I get: The name  ConfigurationHelper does not exist in the current context.

The suggested fixes do not seem right.  What do I need to include in the project  to use this?

1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 30 May 2022, 11:32 AM

Hi Kenneth,

The ConfigurationHelper is a static helper class that we suggest creating in order to help with the loading of the JSON-formatted settings on the application. The code is the following:

using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
static class ConfigurationHelper
{
    public static IConfiguration ResolveConfiguration(IWebHostEnvironment environment)
    {
        var reportingConfigFileName = System.IO.Path.Combine(environment.ContentRootPath, "reportingAppSettings.json");
        return new ConfigurationBuilder()
         .AddJsonFile(reportingConfigFileName, true)
         .Build();
    }
}

This code is part of the Add Configuration Settings (Optional) section of the How to Host Reports Service in ASP.NET Core in .NET 5 along with explanations of what it does and for what scenarios it would be useful.

Regards,
Dimitar
Progress Telerik

Brand new Telerik Reporting course in Virtual Classroom - the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products. Check it out at https://learn.telerik.com/.
Tags
.NET Core
Asked by
Kenneth
Top achievements
Rank 2
Iron
Answers by
Dimitar
Telerik team
Share this question
or