ReportProcessor.RenderReport throwing exception

10 posts, 0 answers
  1. Vlad
    Vlad avatar
    2 posts
    Member since:
    Jul 2015

    Posted 05 Mar Link to this post

    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

     

  2. James
    James avatar
    2 posts
    Member since:
    Nov 2013

    Posted 06 Mar Link to this post

    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;             }         }

  3. Ivan Hristov
    Admin
    Ivan Hristov avatar
    172 posts

    Posted 07 Mar Link to this post

    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
  4. James
    James avatar
    2 posts
    Member since:
    Nov 2013

    Posted 07 Mar in reply to Ivan Hristov Link to this post

    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.
  5. Devesh
    Devesh avatar
    2 posts
    Member since:
    May 2016

    Posted 11 Mar in reply to Ivan Hristov Link to this post

    Hi Ivan,

    Is there an interim workaround for this issue.

  6. Ivan Hristov
    Admin
    Ivan Hristov avatar
    172 posts

    Posted 12 Mar Link to this post

    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
  7. Devesh
    Devesh avatar
    2 posts
    Member since:
    May 2016

    Posted 12 Mar in reply to Ivan Hristov Link to this post

    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.

     

     

  8. Ivan Hristov
    Admin
    Ivan Hristov avatar
    172 posts

    Posted 13 Mar Link to this post

    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
  9. Trung
    Trung avatar
    8 posts
    Member since:
    Jan 2018

    Posted 16 Mar Link to this post

    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 :(
  10. Ivan Hristov
    Admin
    Ivan Hristov avatar
    172 posts

    Posted 19 Mar Link to this post

    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
Back to Top