Rest Service Report viewer.

2 Answers 59 Views
Accessibility
Sathish
Top achievements
Rank 1
Iron
Iron
Iron
Sathish asked on 19 Feb 2025, 06:17 AM | edited on 04 Apr 2025, 12:05 PM
Comment Removed.
Sathish
Top achievements
Rank 1
Iron
Iron
Iron
commented on 21 Feb 2025, 12:35 PM

I believe you are getting ready to provide me with a solution for the issue above.

2 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 07 Apr 2025, 09:25 AM

Hi Sathish,

We have been discussing this case in a separate ticket thread, however, I will also share the advice given in that thread here so that it is available to the public.

Making the Reporting REST Service DPI-Aware

If I understand correctly, in the real-time project, you have connected the WinForms Report Viewer to a Reporting REST Service by following the instructions from the Using the Windows Forms Report Viewer with a REST Service Explained - Telerik Reporting article, is that correct?

However, when looking at the attached projects, I do not see anyone where the Reporting REST Service is implemented and connected to the WinForms Report Viewer. This makes the sample solution fundamentally different from the real-time projects as when the WinForms Report Viewer is connected to a Reporting REST Service, the reports are rendered by the service instead of the embedded engine of the viewer.

This difference is the reason why there are issues with the scaling despite having made the WinForms application DPI-aware judging by the manifest file. The reports will be rendered by the service so to resolve the issue with the scaling, we need to make the service process DPI-aware.

You can do this by using the dpiAware element of the Reporting configuration. You can add it to the appsettings.json file of your API project with the Reporting REST Service. For example:

"telerikReporting": {
    "dpiAware": {
        "dpiAwareness": "PROCESS_PER_MONITOR_DPI_AWARE"
    }
}

Note that I say that the appsettings.json file must be used because of the linked articles such as - Hosting the Reporting REST Service in ASP.NET Core with Minimal API - Telerik Reporting, which suggests that you have an ASP.NET Core application running the reporting service.

If the API application uses XML-based configurations, please take a look at the examples from the dpiAware Element Configuration - Telerik Reporting article instead.

Ensuring that the WinForms application with the WinForms Report Viewer is DPI-Aware

With that being said, despite the reports being rendered on the API project, I would still recommend ensuring that the WinForms application is DPI-aware as well. In those sample projects, you have added a manifest file with the necessary settings. However, to be sure that it takes effect in your real-time application, please try to check on runtime if the process is DPI-aware with the following code:

using System;
using System.Runtime.InteropServices;

public class DpiAwarenessChecker
{
    [DllImport("shcore.dll")]
    private static extern int GetProcessDpiAwareness(IntPtr hprocess, out int awareness);

    public static bool IsDpiAware()
    {
        int awareness;
        var result = GetProcessDpiAwareness(IntPtr.Zero, out awareness);
        return result == 0 && awareness != 0; // awareness 0 means DPI unaware
    }
}

Execute the "IsDpiAware()" static method when the WinForms application loads and inspect whether it returns true.

Using InstanceReportSource when using a Reporting REST Service

I saw your replies in the Rest Service Report viewer. in UI for WinForms | Telerik Forums thread as well and one of them was about issues with using the InstanceReportSource object in the scenario of a WinForms Report Viewer connected to a Reporting REST Service.

In this scenario, the InstanceReportSource object must be created and resolved with a custom IReportSourceResolver because the service application is the one that renders the reports.

You can take a look at the Using Custom ReportSource Resolver and Custom ReportDocument Resolver - Telerik Reporting article for more information and examples on how to create and use a custom resolver that returns an InstanceReportSource object.

Wrapping Up

I hope that the provided information and examples will help resolve the issue. I will attach a sample project with the enabled DPI-awareness setting so that you can use it for reference in your API project.

Regards,
Dimitar
Progress Telerik

Enjoyed our products? Share your experience on G2 and receive a $25 Amazon gift card for a limited time!

-1
Todor
Telerik team
answered on 21 Feb 2025, 04:08 PM

Hi Sathish,

Did you reference the assembly Telerik.Reporting.Services.HttpClient.dll and the assembly hosting your CS reports in the Reporting REST Service project?

The first is required for communication with the service. I suggest adding it as a Nuget package, which will automatically add its dependencies.

Please, note that the reports should be available for the service as the viewer requests the reports from there. The engine instantiates these report types with reflection.

Please, ensure also your assembly with the report definitions is trusted as elaborated in the article section Security Best Practices - Reporting Specific Considerations - Report Definitions.

The ReportEngineConnection's URI generally ends with the Reporting endpoint 'api/reports" as shown below. Our CORS-enabled REST Service demos expose the same endpoint:

"engine=RestService;uri=http://localhost:12345/api/reports;useDefaultCredentials=False;timeout=100;keepClientAlive=True"

The ReportEngineConnection specifies the assembly 'Nts.Suite.dll', version=12.12.9181.20918 as a source for your reports. You need to have it referenced in the REST Service project and ensure its DLL is accessible by the service in runtime.

I have linked a muted video showing how I modified our WinForms demo viewer to display reports from our ReportLibrary through the demo REST Service. The ReportLibarary is referenced there by design.

I suggest also opening a Support Ticket if you need faster responses to your questions. You will be able also to attach a runnable project to the ticket, so we may try to help troubleshoot it.

Regards,
Todor
Progress Telerik

Enjoyed our products? Share your experience on G2 and receive a $25 Amazon gift card for a limited time!

Sathish
Top achievements
Rank 1
Iron
Iron
Iron
commented on 25 Feb 2025, 07:41 PM

Hi Todor.

I have faced many issues in this and fixed them as well. But I am still facing some problems.

After all my investigations and experience with these new issues, I feel like there may be an issue with this method

I am not sure where is the issue. But I am guessing ReportSource may be the cause for this issue.

 

 

The issue I am getting is:

This is my MAINFORM I am trying to show this inside Mainform(As a child). But below exception is thrown.

Please let me know if you have any questions. 

 

Thanks.

 

Dimitar
Telerik team
commented on 28 Feb 2025, 12:32 PM

Hi Sathish,

The error message suggests that the report cannot be resolved. When using type(.CS) reports, the cause for the error is usually that either the given type string is wrong or the assembly with this type is not referenced in the project where the reports are rendered.

I see from the first image that you are using an InstanceReportSource so the type should resolve successfully in the WinForms project(otherwise there would be errors on build). However, when the WinForms Report Viewer is connected to a Reporting REST Service, the reports are rendered on the service project and the report types, as well as all dependencies used in the report, should also be referenced in the service project.

Todor mentioned it in his reply but I did not see it confirmed in your last response so I would like to again ask - is the assembly 'Nts.Suite.dll', version=12.12.9181.20918 the source for your report types, and if yes, have you referenced it in the REST Service project?

If the issue persists even when the assembly is added there, please attach a sample project where the issue is reproduced so that I can debug it. You may also generate and send me a trace log from the service project - How to: Create and Initialize Trace Listeners - .NET Framework | Microsoft Learn.

Thank you for your cooperation.

 

Sathish
Top achievements
Rank 1
Iron
Iron
Iron
commented on 28 Feb 2025, 08:50 PM

Hi Dimitar.

I followed all the steps outlined by Todor, but unfortunately, nothing worked.

 

I will create a sample application and attach it to this conversation asap.I have currently stopped working on this task.

 

Thanks

Sathish
Top achievements
Rank 1
Iron
Iron
Iron
commented on 02 Apr 2025, 12:28 PM

Hi Dimitar,

 

I have a fully readymade InstanceReportSource. This is how we are applying the report source, as shown below.

public void SetReportSource(InstanceReportSource reportSource)
{
     this.radReportViewer.ReportSource = reportSource;
}

This 'InstanceReportSource reportSource' contains everything that is required (Columns, Data, Header, etc...). I am not able to map this with the REST Reporting project. I have 1,000s of reports, and everything should work dynamically.

Please help me with the solution.

 

Please let me know if you have any doubts about my question.

Thank you.

 

Sathish
Top achievements
Rank 1
Iron
Iron
Iron
commented on 02 Apr 2025, 03:23 PM | edited

Removed comment for security reason.
Tags
Accessibility
Asked by
Sathish
Top achievements
Rank 1
Iron
Iron
Iron
Answers by
Dimitar
Telerik team
Todor
Telerik team
Share this question
or