Telerik Report Generation Fails in IIS on Azure VM with OperationCanceledException

2 Answers 14 Views
.NET Core Programming
Lasitha
Top achievements
Rank 1
Iron
Lasitha asked on 09 Oct 2025, 09:28 AM

I have a .NET Core Web API that generates reports using Telerik Reporting. The report generation works perfectly in my local development environment, but when deployed to an Azure VM with IIS, it fails immediately with OperationCanceledException. The operation doesn't even wait for the configured 5-minute timeout.

The issue is intermittent. It works sometimes but suddenly stops working without any code changes.

Error Stack Trace

The operation was canceled.     at System.Threading.CancellationToken.ThrowOperationCanceledException()
   at System.Threading.ManualResetEventSlim.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at System.Threading.Tasks.Task.SpinThenBlockingWait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at System.Threading.Tasks.Task.InternalWaitCore(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at System.Threading.Tasks.Task.Wait(CancellationToken cancellationToken)
   at Telerik.Reporting.Paging.PageCompositionBase.SeparateThreadOutputBehavior.Finish()
   at Telerik.Reporting.Paging.PageCompositionBase.CreatePages()
   at Telerik.Reporting.Paging.PagerBase.Telerik.Reporting.Paging.IPager.CreatePages(IPageHandler handler, LayoutElement root)
   at Telerik.Reporting.BaseRendering.RenderingExtensionBase.Render(LayoutElement root, Hashtable renderingContext, Hashtable deviceInfo, CreateStream createStreamCallback, EvaluateHeaderFooterExpressions evalHeaderFooterCallback, PageSettings pageSettings)
   at Telerik.Reporting.BaseRendering.RenderingExtensionBase.Render(Report report, Hashtable renderingContext, Hashtable deviceInfo, CreateStream createStreamCallback, EvaluateHeaderFooterExpressions evalHeaderFooterCallback)
   at Telerik.Reporting.Processing.ReportProcessor.RenderCore(ExtensionInfo extensionInfo, IList`1 processingReports, Hashtable deviceInfo, IRenderingContext renderingContext, CreateStream createStreamCallback)
   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, CreateStream createStreamCallback, CancellationToken cancellationToken, String& documentName)


here is the code for report generation

public SalesSummaryDataOutput SalesSummaryReport(SalesReportSummaryRequest requestReport)
{
    string reportPath = "\\Reports\\" + ReportTypes.SalesSummary.ToString() + ".trdx";
    var reportProcessor = new ReportProcessor();
    var deviceInfo = new Hashtable();
    var reportSource = new UriReportSource();

    reportSource.Uri = _hostEnvironment.ContentRootPath + reportPath;
    reportSource.Parameters.Add("FromDate", requestReport.FromDate);
    reportSource.Parameters.Add("ToDate", requestReport.ToDate);
    reportSource.Parameters.Add("CompanyId", requestReport.CompanyId);
    reportSource.Parameters.Add("LocationId", requestReport.LocationId);
    reportSource.Parameters.Add("UserId", requestReport.UserId);
    reportSource.Parameters.Add("ExecuteReport", true);

    deviceInfo["OutputFormat"] = "PNG";
    deviceInfo["DpiX"] = 192;
    deviceInfo["DpiY"] = 192;
    deviceInfo["Timeout"] = 300000;
    deviceInfo["ThreadCulture"] = CultureInfo.CurrentCulture.Name;

    try
    {
        CloseStreams();
        string documentName = "ReportDocument";
        var cts = new CancellationTokenSource(TimeSpan.FromMinutes(5));
        bool result = reportProcessor.RenderReport("IMAGE", reportSource, deviceInfo, CreateStream, cts.Token, out documentName);

        if (result)
        {
            var salesSummaryReport = new SalesSummaryDataOutput();
            foreach (var stream in _streams)
            {
                byte[] imageData = ReadToEnd(stream);
                string base64String = Convert.ToBase64String(imageData, 0, imageData.Length);
                salesSummaryReport.ReportImages.Add(base64String);
            }
            CloseStreams();
            return salesSummaryReport;
        }
    }
    catch (Exception ex)
    {
        var salesSummaryReport = new SalesSummaryDataOutput();
        salesSummaryReport.ReportImages.Add($"Error: {ex.Message}");
        CloseStreams();
        return salesSummaryReport;
    }

    return new SalesSummaryDataOutput();
}

Why does the cancellation happen immediately in IIS but not locally?

What could cause this intermittent behavior?

Are there specific IIS or Telerik configurations I'm missing?

2 Answers, 1 is accepted

Sort by
0
Accepted
Lasitha
Top achievements
Rank 1
Iron
answered on 15 Oct 2025, 12:05 PM

The issue was caused by a missing font on the new Windows server. Some reports failed to render because they used the Arial font, which wasn’t installed, while others worked fine using Times New Roman. The fix was simply to change the font in the report file to a font that exists on the server, such as Times New Roman. After updating the font and redeploying the report, it rendered successfully without any errors.

0
Dimitar
Telerik team
answered on 13 Oct 2025, 02:01 PM

Hello Lasitha,

Thank you for the provided information about the problem!

The most common reason for the report rendering to fail when hosted on Azure is that it is a Windows-based VM where the GDI+ APIs are not available, you can read more about this in the Use Report Viewers with REST Service on Azure - Telerik Reporting article.

You may either upgrade to a higher tier subscription where GDI is included, or you may try using our SkiaSharp-based graphics engine. To do that, you need to install the Telerik.Drawing.Skia NuGet package in your project, and you also need to specify in appsettings.json that Skia should be used:

"telerikReporting": {
    "processing": {
            // The element below sets the graphics engine used for measurement and rendering. Available values for engineName: "Skia", "Gdi", "PlatformDependent". Default value: PlatformDependent.
        "graphicsEngine": {
            "engineName": "Skia" 
        }
 }

For more information on changing the Reporting configuration, you can take a look at the Configuring the processing Element - Telerik Reporting article.

I hope that the provided information will help.

Regards,
Dimitar
Progress Telerik

Your perspective matters! Join other professionals in the State of Designer-Developer Collaboration 2025: Workflows, Trends and AI survey to share how AI and new workflows are impacting collaboration, and be among the first to see the key findings.
Start the 2025 Survey
Tags
.NET Core Programming
Asked by
Lasitha
Top achievements
Rank 1
Iron
Answers by
Lasitha
Top achievements
Rank 1
Iron
Dimitar
Telerik team
Share this question
or