Invalid Parameter when running from Azure Web App

1 Answer 73 Views
Report Parameters
Taras
Top achievements
Rank 3
Iron
Iron
Veteran
Taras asked on 28 Jun 2024, 03:54 PM

I have a in an ASP.net Core 6 application.

When I run the app from my laptop from VS 2022, it works correctly.  It also run correctly when doing a Preview from the standalone report developer. (Telerik Report Designer v17.0.23.118)

When I try to run it from the Azure web app (using the same data source), after publishing I get an error saying parameter is not valid.  Partial trace below. 

I've verified that a valid parameter is being passed to the report. I can run the preview successfully using the same parameter value that's being used in the app.

The report was working before, but I need to make a change to the body.  The report creates a PDF of the record displayed on the web page at the time.

Has anyone experienced something like this before?  Where should I be looking for the error?

System.Exception: Parameter is not valid. at System.Drawing.SafeNativeMethods.Gdip.CheckStatus(Int32 status) at System.Drawing.Graphics.GetHdc() at
Telerik.Reporting.Pdf.PdfContext..ctor(String ownerPassword, String userPassword) at Telerik.Reporting.Pdf.PdfDocument.InitCompleted(Stream stream) at Telerik.Reporting.ImageRendering.PdfRenderingContext.InitPdfDocument(PdfDocument pdfDocument, Stream stream) at Telerik.Reporting.ImageRendering.DocumentPdf.CreateDocument(PdfRenderingContext pdfContext) at Telerik.Reporting.ImageRendering.DocumentPdf.ResolveDocument() at Telerik.Reporting.ImageRendering.DocumentPdf..ctor(PdfRenderingContext context, IMeasureContext measureContext) at Telerik.Reporting.ImageRendering.PdfReport.CreateDocument(IDictionary renderingInfo, IDictionary deviceInfo, CreateStream createStreamCallback, PageSettings pageSettings) at Telerik.Reporting.BaseRendering.DocumentRenderingExtensionBase.CreateWriter(IDictionary renderingContext, IDictionary deviceInfo, CreateStream createStreamCallback, PageSettings pageSettings) at Telerik.Reporting.ImageRendering.PdfReport.CreateWriter(IDictionary renderingContext, IDictionary deviceInfo, CreateStream createStreamCallback, PageSettings pageSettings) 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.<>c__DisplayClass47_0.

1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 02 Jul 2024, 01:10 PM

Hello Taras,

Thank you for the provided information!

The "Parameter is not valid" exception message is likely not referring to the report parameters of the report. The reason I think so is because it seems to be thrown by the System.Drawing.SafeNativeMethods.Gdip.CheckStatus(Int32 status) method.

Based on the exception message, I assume that the argument Int32 status passed to the method System.Drawing.SafeNativeMethods.Gdip.CheckStatus is not valid. Unfortunately, it is not clear why, since the method is called internally by the System.Drawing functionality.

We have previously observed a similar issue, and it was resolved after increasing the memory on the Azure plan. The StackOverflow thread "Parameter is not valid" Thrown from System.Drawing.Graphics.GetHdc()-- Only on Some Machines elaborates on a leak in GDI objects that would increase the memory consumption and may lead to an out-of-memory exception that is masked by the GDI+. Can you try to increase the memory?

The problem may also be that the Azure plan that you use doesn't support fully the GDI+ implemented by System.Drawing. You may check the KB article Preview Reports in Desktop Viewers Using REST Service Deployed in Azure for details.

Do you use private fonts? If so, we are aware of some problems with Azure and they are described in the article privateFonts Element.

Please, check the above suggestions and let us know how it goes.

Regards,
Dimitar
Progress Telerik

Stay tuned by visiting our roadmap and feedback portal pages, enjoy a smooth take-off with our Getting Started resources, or visit the free self-paced technical training at https://learn.telerik.com/.
Taras
Top achievements
Rank 3
Iron
Iron
Veteran
commented on 02 Jul 2024, 04:53 PM

The first link provided  regarding GDI issue has a secondary link in the response that is no longer valid.

I do not have any private fonts.

I upgraded the Azure Service Plan from D1 to B1 and that resolved the issue.

Tags
Report Parameters
Asked by
Taras
Top achievements
Rank 3
Iron
Iron
Veteran
Answers by
Dimitar
Telerik team
Share this question
or