Error in Report only on Production Server and not on Developer Machine

0 Answers 66 Views
DataSource SQL DataSources Report Viewer - ASP.NET Report Viewer - HTML5
Alexandre
Top achievements
Rank 2
Iron
Iron
Iron
Alexandre asked on 04 Jul 2023, 10:25 PM

Hello,

I am getting the following error when trying to print a report from my website:

But when in my local machine, it displays correctly. The database is the same, no changes between then.

Regards,

Alexandre

Dimitar
Telerik team
commented on 07 Jul 2023, 12:53 PM

Hi Alexandre,

The only scenario where I can imagine this happening on only one of the servers is if the production server does not have the used by the data source data provider installed on it and is instead falling back to another data provider.

Please check whether that is the case. Also, if you have an ASP.NET Core project, check whether your provider is among the ones we support by default or if you need to register it manually - How to register a new DbProviderFactory instance in a .NET Core project - Telerik Reporting.

If further assistance would be needed, please record and attach to your next response a trace log generated on the production server - How to troubleshoot errors in ASP.NET Core projects - Telerik Reporting

Alexandre
Top achievements
Rank 1
commented on 12 Jul 2023, 11:01 AM

Hello Dimitar,

I have tried to use the following sugestion:

Please check whether that is the case. Also, if you have an ASP.NET Core project, check whether your provider is among the ones we support by default or if you need to register it manually - How to register a new DbProviderFactory instance in a .NET Core project - Telerik Reporting.

But I am unable to put it into the code, as it gives me errors I can not solve. Could you please provide a code snipet using: 

DBPROVIDERFACTORY TYPE NAME System.Data.SqlClient.SqlClientFactory

Regards,

Alexandre

Momchil
Telerik team
commented on 17 Jul 2023, 07:28 AM

Hello Alexandre,

The System.Data.SqlClient.SqlClientFactory is among the db providers we support by default so I believe that adding it explicitly should not be necessary.

However, here is a sample code snippet you can use, just in case.

[Route("api/reports")]
public class ReportsController : ReportsControllerBase
{
    public ReportsController(IReportServiceConfiguration reportServiceConfiguration)
        : base(reportServiceConfiguration)
    {
        Telerik.Reporting.Processing.Data.DbProviderFactories.RegisterFactory("System.Data.SqlClient", System.Data.SqlClient.SqlClientFactory.Instance);
    }
}

Also, if you are using a named connection string in your report, it might be useful to check if the providerName of the connection is changed based on the environment. For example:

// appsettings.Production.json
{
  "ConnectionStrings": {
    "ReportConnectionName": { 
      "connectionString": "...",
      "providerName": "UnexpectedProviderName"
    }
  }
} 

If the above does not resolve the issue, please record the trace log my colleague Dimitar mentioned and attach it to your message. It should contain more information about the issue and, hopefully, give us a hint about how to fix it.

Alexandre
Top achievements
Rank 2
Iron
Iron
Iron
commented on 23 Jul 2023, 02:38 PM | edited

Hello Momchil,

I have tried using the sugested code snippet but nothing changed. I have managed to create the LOG file, wich will be attached to this comment.

The connection string is not a problem because the data source is embedded in the report.

Regards,

Alexandre

 

Momchil
Telerik team
commented on 27 Jul 2023, 07:51 AM

Hello Alexandre,

Thank you for recording the trace log.

Judging by the trace, it looks like the System.Data.SqlClient data provider cannot resolve the schema of the SQL connection.

Since the data source is embedded in the report, its data provider should be serialized in the report definition. Could you open the data source configuration wizard and check which data provider is selected?

If it is something other than the default data providers, you would need to register it explicitly using the approach we discussed earlier. Perhaps the report requires the newer Microsoft.Data.SqlClient?

Other than that, I see that your project is loading the .NETStandard version of the Telerik.Reporting assembly. Could you confirm what type of project you are using? If you have a .NET Framework project and refer the .NETStandard assembly, unexpected behavior like this one can occur.

No answers yet. Maybe you can help?

Tags
DataSource SQL DataSources Report Viewer - ASP.NET Report Viewer - HTML5
Asked by
Alexandre
Top achievements
Rank 2
Iron
Iron
Iron
Share this question
or