This is a migrated thread and some comments may be shown as answers.

Reporting & ASP.NET Core

8 Answers 305 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Reafidy
Top achievements
Rank 1
Reafidy asked on 26 Oct 2017, 12:11 AM

I have failed to setup a project as instructed here:

https://docs.telerik.com/reporting/html5-report-viewer-asp-net-core-2

I have been over the instructions 10 times, the error message I receive is.

Error registering the viewer with the service.

An error has occurred.
The type initializer for 'Lock' threw an exception.

Project found here:

https://www.dropbox.com/s/8rl4hhanj5gbfc9/WebApplication2.zip?dl=0

8 Answers, 1 is accepted

Sort by
0
Katia
Telerik team
answered on 30 Oct 2017, 10:49 AM
Hello Reafidy,

The project you attached targets .NET Core framework. Telerik Reporting .NET Core packages are built against full .NET Framework because the Reporting engine relies on the GDI+ API.

To create the .NET Core project that will host the REST service:

1. In the New Project dialog, expand Installed > Visual C# > .NET Core, and select ASP.NET Core Web Application project template. Choose a name for the project and click OK.

2. On the New ASP.NET Core Web Application dialog select from the drop downs .NET Framework and ASP.NET Core 2. Next from the list of templates select Web API.

You can check HTML5 Report Viewer in ASP.NET Core 2 help article for further instructions on how to host the service and add HTML5 Viewer to this type of projects.

If you wish to target non-Windows platforms with ASP.NET Core Application you can add HTML5 Viewer as a JavaScript widget which does not require any Telerik NuGet packages. Reporting REST service can be hosted separately in a MVC 5 project where the HTML5 Viewer will need the address of the service to display reports produced on the remote machine. More details on how to host Reporting REST Service can be found in the following help articles:

How To: Add Telerik Reporting REST Web API to Web Application 
How To: Self Host Telerik Reporting REST Web API


I hope this information will help.


Regards,
Katia
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Reafidy
Top achievements
Rank 1
answered on 31 Oct 2017, 03:10 AM

 I cannot change the target framework to the .net framework unfortunately due to other company reasons.

So are you saying there is no way at all to display a Telerik report in a .net core targeted app.  Even with a separate class library or Rest service?

0
Accepted
Katia
Telerik team
answered on 31 Oct 2017, 07:50 AM
Hi Reafidy,

In your current project you can add just HTML5 Viewer, it does not require any NuGet packages and will need only the address of the Reporting REST service set as its serviceUrl option. The service can be hosted in a separate project that targets the standard framework. For more details on how to host the service check:
How To: Add Telerik Reporting REST Web API to Web Application 
How To: Self Host Telerik Reporting REST Web API

Important
: when the service is hosted in a separate project it is necessary to enable CORS to allow the communication between the viewer and the service.


Regards,
Katia
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Reafidy
Top achievements
Rank 1
answered on 01 Nov 2017, 10:29 AM

I have created an app which targets the .NETCORE 2 Framework.  It uses a Rest Service for the reporting side.  The rest service has CORS enabled as you mentioned and the .netcore project simply has the html 5 viewer.

I am getting this error:
Error loading the report viewer's templates. (Template = http://localhost:12345/api/reports/resources/templates/telerikReportViewerTemplate-html).
Even though if I click the above link the template is loaded.

Please can you amend the project I have provided to work.  
*link removed due to sensitive information*

0
Bollini
Top achievements
Rank 1
answered on 01 Nov 2017, 10:03 PM
I am also facing same issue when i use Telerik reporting with .net core with core 2.0. Is there any fix in near future release?
0
Bollini
Top achievements
Rank 1
answered on 01 Nov 2017, 10:08 PM

when i use Telerik reporting with .net core with core 2.0. below error

Error registering the viewer with the service.
An error has occurred.
The type initializer for 'Lock' threw an exception.

0
Nasko
Telerik team
answered on 03 Nov 2017, 04:04 PM
Hello Readify,

We replied to your question in your private support thread. I will also copy this answer here if anyone else is facing the same issue:

The provided web application is unable to access the Reporting REST Service due to CORS issues: screenshot.
We followed the articles provided previously and modified the Global.asax and WebApiConfig files, together with the ReportsController file accordingly. Then, starting both projects simultaneously, the viewer showed up as expected: screenshot.


@Bollini
The error message is different in your scenario. Please open a separate support ticket where you can provide additional information/samples.

Regards,
Nasko
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Reafidy
Top achievements
Rank 1
answered on 06 Nov 2017, 06:00 AM

Note that when enabling cors like so:

[EnableCors(origins: "http://localhost:49906", headers: "*", methods: "*")]
public class ReportsController : ReportsControllerBase

 

A complete clean and rebuild of the project is required to push the changes.

Tags
General Discussions
Asked by
Reafidy
Top achievements
Rank 1
Answers by
Katia
Telerik team
Reafidy
Top achievements
Rank 1
Bollini
Top achievements
Rank 1
Nasko
Telerik team
Share this question
or