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

ReportProcessor.RenderReport throwing exception

9 Answers 1411 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Vlad
Top achievements
Rank 1
Vlad asked on 05 Mar 2018, 07:35 PM

Hi,

we try generating reports on the server simultaneously:

Parallel.ForEach(x, x =>

{

...

ReportProcessor.RenderReport(...);

....

}

and get the occasional exception below:

 

System.AggregateException: One or more errors occurred. ---> Telerik.Reporting.Processing.CancelProcessingException: An error occurred while evaluating the report parameters. Report source cannot be processed. ---> System.ArgumentNullException: Value cannot be null.

Parameter name: path2
   at System.IO.Path.Combine(String path1, String path2, String path3)
   at Telerik.Reporting.Interfaces.LocalizationContext.InitializeBucket(String resx)
   at Telerik.Reporting.Interfaces.LocalizationContext.GetString(String resx, String key)
   at Telerik.Reporting.Interfaces.StringsResolver.GetString(String key)

   at Telerik.Reporting.SRDescriptionAttribute.get_Description()
   at Telerik.Reporting.Expressions.EnumContextManager.GetItem(Type enumType)
   at Telerik.Reporting.Processing.ReportExpressionContext.RegisterAllReportingEnums()
   at Telerik.Reporting.Processing.ReportExpressionContext..ctor(Type reportType)
   at Telerik.Reporting.Processing.ReportParametersManager`1.CreateExpressionContext(Report report, IList`1 runtimeParameters)
   at Telerik.Reporting.Processing.ReportParametersManager`1..ctor(Report definitionReport, IEnumerable`1 definitionParameters, IDictionary`2 reportSourceParameters, IDataProviderContext dataProviderContext)
   at Telerik.Reporting.Processing.DocumentParametersManager`1.CreateManager(Report definition, IDataProviderContext dataProviderContext, IParameterValueParser parameterValueParser, IDictionary`2 rsParameters)
   at Telerik.Reporting.Processing.DocumentParametersManager`1.CreateManagers(IProcessingContext context, IParameterValueParser parameterValueParser)
   at Telerik.Reporting.Processing.DocumentParametersManager`1..ctor(ResolvedReportDocument resolvedReports, IProcessingContext processingContext, IParameterValueParser parameterValueParser)
   at Telerik.Reporting.Processing.ReportProcessor.ProcessReportSource(ReportSource reportSource, IRenderingContext context)
   --- End of inner exception stack trace ---
   at Telerik.Reporting.Processing.ReportProcessor.ProcessReportSource(ReportSource reportSource, IRenderingContext context)
   at Telerik.Reporting.Processing.ReportProcessor.ProcessReportSource(ReportSource reportSource, Hashtable deviceInfo, IRenderingContext context)
   at Telerik.Reporting.Processing.ReportProcessor.ProcessAndRender(String format, ReportSource reportSource, Hashtable deviceInfo, IRenderingContext renderingContext, CreateStream createStreamCallback)
   at Telerik.Reporting.Processing.ReportProcessor.ProcessAndRenderStateless(String format, ReportSource reportSource, Hashtable deviceInfo, IRenderingContext renderingContext, CreateStream createStreamCallback)
   at Telerik.Reporting.Processing.ReportProcessor.RenderReport(String format, ReportSource reportSource, Hashtable deviceInfo)

 

All the reporting assemblies are the latest.

Can the issue be related to?:

https://www.telerik.com/forums/is-the-reportprocessor-renderreport-function-thread-safe

 

Thank you,

Vlad

 

9 Answers, 1 is accepted

Sort by
0
James
Top achievements
Rank 1
answered on 06 Mar 2018, 05:38 PM

I'm getting the same error, not doing anything fancy with parallel processing.  Just trying to render from a controller.

public ActionResult PrintReport(CommitmentCardConfigurationViewModel vm)         {             var typeReportSource = new Telerik.Reporting.TypeReportSource();             typeReportSource.TypeName = typeof(FieldReports.CommittmentCards.MasterListRegionByLocal).AssemblyQualifiedName;             typeReportSource.Parameters.Add(new Telerik.Reporting.Parameter() { Name = "regionNumber", Value = vm.SelectedRegion });             

    ExportToPDF(typeReportSource, vm.SelectedRegion);             return new ContentResult() { Content = "" };         }         public void ExportToPDF(Telerik.Reporting.TypeReportSource reportToExport, string regionNumber)         {             ReportProcessor reportProcessor = new ReportProcessor();             try             {                 RenderingResult result = reportProcessor.RenderReport("PDF", reportToExport, null);                 //string fileName = $"{result.DocumentName}_{regionNumber}." + result.Extension;                 //Response.Clear();                 //Response.ContentType = result.MimeType;                 //Response.Cache.SetCacheability(HttpCacheability.Private);                 //Response.Expires = -1;                 //Response.Buffer = true;                 //Response.AddHeader("Content-Disposition",                 //                   string.Format("{0};FileName=\"{1}\"",                 //                                 "attachment",                 //                                 fileName));                 //Response.BinaryWrite(result.DocumentBytes);                 //Response.End();             }             catch (Exception ex)             {                 throw;             }         }

0
Ivan Hristov
Telerik team
answered on 07 Mar 2018, 09:12 AM
Hello,

The issue, observed by Vlad Skobelev, is due to incorrect initialization of a LocalizationContext instance, when accessed simultaneously by two or more threads. It is already fixed and will be published in an internal build later this month.

However, when only a single thread executes the RenderReport() method of the ReportProcessor, the problem should not occur. I tested the code James posted and it works flawlessly, as expected. So I would like to ask James to help us further while investigating the problem and provide a stack trace and a runnable project so we can test it on our side.

Regards,
Ivan Hristov
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
James
Top achievements
Rank 1
answered on 07 Mar 2018, 01:27 PM
Upon further review, my method was being called twice in succession on different threads due to an error elsewhere in my code.  Once that issue was resolved, it did indeed render properly.
0
Devesh
Top achievements
Rank 1
answered on 12 Mar 2018, 04:43 AM

Hi Ivan,

Is there an interim workaround for this issue.

0
Ivan Hristov
Telerik team
answered on 12 Mar 2018, 07:25 AM
Hello Devesh,

The workaround is to call the RenderReport() method just once before executing the parallel block. This will allow the LocalizationContext instance to be properly initialized. This preliminary call doesn't have to render the same report - its ReportSource can just represent a new report instance, as shown below:
new ReportProcessor().RenderReport(
    "PDF",
    new InstanceReportSource()
    {
        ReportDocument = new Telerik.Reporting.Report()
    },
    null);
 
var rs = new TypeReportSource() { TypeName = typeof(BarcodesReport).AssemblyQualifiedName };
Parallel.ForEach(Enumerable.Range(1, 10).ToList(), e =>
{
    var result = new ReportProcessor().RenderReport("PDF", rs, null);
    System.IO.File.WriteAllBytes("c:\\temp\\report_" + e + ".pdf", result.DocumentBytes);
});


Regards,
Ivan Hristov
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
Devesh
Top achievements
Rank 1
answered on 12 Mar 2018, 08:42 AM

Hi Ivan,

We have a job scheduler(Hangfire) that is processing parallel jobs which further render telerik Reports as excel book in every job. So, with your suggested workaround it appears that you are suggesting to add a lock for initialisation of ReportSource. Kindly confirm our understanding. In addition to this we have following queries:

1) We have just upgraded our Telerik version from 10.2.16.914 to 12.0.18.125. So, is this issue present only in latest version 12.0.18.125 or previous version as well?

2) When will the hotfix be released for this issue.

 

 

0
Ivan Hristov
Telerik team
answered on 13 Mar 2018, 09:28 AM
Hi Devesh,

The issue in question is not related with the ReportSource, but with the ReportProcessor, so a lock is not necessary. The idea is to call the ReportProcessor's RenderReport() method in the main thread before the Parallel.ForEach block, so its LocalizationContext instance would be properly initialized. However, if in your code there is a chance two threads to execute the first RenderReport() call, then the lock is a must.

The issue is introduced in R1 2018 (12.0.18.117) along with the new localization feature.The versions prior to 12.0.18.117 will work in parallel processing scenarios, so you can downgrade to R3 2017 until the fix is published.

The internal build containing the fix will be released later this week or early next week, if the fixes successfully pass the QA stages.

Thank you for your understanding.

Regards,
Ivan Hristov
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
Trung
Top achievements
Rank 1
answered on 17 Mar 2018, 01:45 AM
I got hit with the same problem. Will the internal build fixes goes into a beta or release version? I can't really use an internal build version :(
0
Ivan Hristov
Telerik team
answered on 19 Mar 2018, 07:54 AM
Hi Trung,

We're sorry for the inconvenience caused. The issue is fixed in internal build 12.0.18.315 from March, 15th. and currently we do not plan to publish another service pack release. If installing an internal build is not an option, you can use the workaround described in the previous posts.

Regards,
Ivan Hristov
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
Tags
General Discussions
Asked by
Vlad
Top achievements
Rank 1
Answers by
James
Top achievements
Rank 1
Ivan Hristov
Telerik team
Devesh
Top achievements
Rank 1
Trung
Top achievements
Rank 1
Share this question
or