MVC 5 / Stimulsoft 2018.2.1 / Generic error in GDI+

Stimulsoft Reports.NET discussion
Post Reply
triminformatica
Posts: 3
Joined: Tue Jun 26, 2018 1:08 pm

MVC 5 / Stimulsoft 2018.2.1 / Generic error in GDI+

Post by triminformatica »

OS: Windows Server 2016 / .NET: 4.5 / MVC 5 / Stimulsoft 2018.2.1

Hello to everyone,
we have a MVC application with StiMvcViewer component in a CSHTML page. We deployed this app on IIS 10.0. Usually the viewer works well, but sometimes (about two times a week) it gives us the following error:

"ERROR: A generic error occurred in GDI+
System.Runtime.InteropServices.ExternalException (0x80004005): A generic error occurred in GDI+.
at System.Drawing.Image.Save(Stream stream, ImageCodecInfo encoder, EncoderParameters encorderParams)
etc...".

This error is not predictable so at the moment we only have a screenshot, attached to this topic.

We are sure that it not depends on the size of the report requested (we checked with few lines). Once the error comes no more reports, unless we restart the Application Pool in IIS.
Have you ever seen this kind of error? Do you know why there's need to restart Application Pool? (restarting the current site only doesn't work).

Thanks and regards,
Max
Attachments
screenshot of the error
screenshot of the error
stimulsoft_error.png (75.2 KiB) Viewed 2078 times
HighAley
Posts: 8431
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: MVC 5 / Stimulsoft 2018.2.1 / Generic error in GDI+

Post by HighAley »

Hello, Andrea.

How many reports are compiled before you get this error?
Please, check if there is enough free memory.
You could get this error because of the many report assemblies loaded into the meemory.
Is there x86 or x64 application?

Please, read the Using report assemblies article.
You could find a scenario for you.

Thank you.
triminformatica
Posts: 3
Joined: Tue Jun 26, 2018 1:08 pm

Re: MVC 5 / Stimulsoft 2018.2.1 / Generic error in GDI+

Post by triminformatica »

Hello, it happened again today. We updated our App (after stopping Application Pool and Site) and then, after few reports (4-5) we got the same error. We can still download the generated report in any format (PDF etc..), only online viewer breaks.
The app is x86, and it's hosted on a plenty of memory server (VM running on a big industrial server, 16GB ram allocated for this particular VM). We checked RAM used when generating reports and there's a very little impact.

That's full error by the way:

System.Runtime.InteropServices.ExternalException (0x80004005): A generic error occurred in GDI+.
at System.Drawing.Image.Save(Stream stream, ImageCodecInfo encoder, EncoderParameters encoderParams)
at System.Drawing.Image.Save(Stream stream, ImageFormat format)
at Stimulsoft.Report.StiImageCache.AddImageInt(Image image, ImageFormat imageFormat)
at Stimulsoft.Report.Export.StiHtmlImageHost.GetImageString(Bitmap bmp)
at Stimulsoft.Report.Export.StiHtmlTableRender.RenderTable(Boolean renderStyles, String backGroundImageString, Boolean useBookmarks, Boolean exportBookmarksOnly, Hashtable cssStyles)
at Stimulsoft.Report.Export.StiHtmlExportService.ExportHtml(StiReport report, StiHtmlTextWriter writer, StiHtmlExportSettings settings, StiPagesCollection pages)
at Stimulsoft.Report.Export.StiHtmlExportService.ExportHtml(StiReport report, Stream stream, StiHtmlExportSettings settings)
at Stimulsoft.Report.Web.StiReportHelper.GetReportPage(StiReport report, StiHtmlExportService service, Int32 pageIndex, StiRequestParams requestParams)
at Stimulsoft.Report.Web.StiReportHelper.GetPagesArray(StiReport report, StiRequestParams requestParams)
at Stimulsoft.Report.Web.StiReportHelper.ViewerResult(StiRequestParams requestParams, StiReport report)
at Stimulsoft.Report.Mvc.StiMvcViewer.ViewerEventResult(StiRequestParams requestParams, StiReport report, Boolean detectActionResult)
at Stimulsoft.Report.Mvc.StiMvcViewer.ViewerEventResult()
at TRIM.Mes.Web.Calvi.UI.Controllers.StoricoSchedeController.ViewerEvent()
at lambda_method(Closure , ControllerBase , Object[] )
at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__36(IAsyncResult asyncResult, ActionInvocation innerInvokeState)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3c()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass45.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3e()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass30.<BeginInvokeActionMethodWithFilters>b__2f(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass1e.<>c__DisplayClass28.<BeginInvokeAction>b__19()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass1e.<BeginInvokeAction>b__1b(IAsyncResult asyncResult)

Thanks and regards
Lech Kulikowski
Posts: 6247
Joined: Tue Mar 20, 2018 5:34 am

Re: MVC 5 / Stimulsoft 2018.2.1 / Generic error in GDI+

Post by Lech Kulikowski »

Hello,

It is difficult to say something exactly only by this error stack.
Could you send us a sample project which reproduces the issue for analysis?

Thank you.
triminformatica
Posts: 3
Joined: Tue Jun 26, 2018 1:08 pm

Re: MVC 5 / Stimulsoft 2018.2.1 / Generic error in GDI+

Post by triminformatica »

Hi again, coming back after holidays.. Also the error in Report Viewer is back. Manually recycling the app pool is the only temporary solution.

Here it is the code:

CONTROLLER:

//index get action, checks filters for report

public ActionResult ReportLavorazioni()
{
FilterLavorazioniDTO fromSession = GetFilterPageModelFromSession<FilterLavorazioniDTO>("LavorazioniFilters",
new Tuple<string, string>("ReportLavorazioni", "Report"));

REPORTListingLavorazioniDTO model = ReportService.GetLavorazioniForReport(fromSession);

return View(model);
}


//index post action, sets filters for report

[HttpPost]
public ActionResult ReportLavorazioni(REPORTListingLavorazioniDTO input)
{
try
{
SetFilterPageModelToSession("LavorazioniFilters", input.Filters);

REPORTListingLavorazioniDTO model = ReportService.GetLavorazioniForReport(input.Filters);

StiReport report = _getReportFromListingLavorazioniDTO(model);

SetReportViewerToSession("ReportViewLavorazioni", report);

return View(model);
}
catch (Exception ex)
{
ViewBag.Errore = ex.Message;

return View();
}
}


//private method, generates reports with filters on

private StiReport _getReportFromListingLavorazioniDTO(REPORTListingLavorazioniDTO input)
{
FilterLavorazioniDTO filtri = input.Filters;

if (input.Filters.StatoLavorazioneSelezionato != null)
filtri.StatoLavorazioneString = input.Filters.DatasourceStatoLavorazione[input.Filters.StatoLavorazioneSelezionato.Value].Text;
if (input.Filters.ImpiantoSelezionato != null)
{
StatoImpiantoDTO impianto = input.Filters.DatasourceImpianto
.Where(m => m.Id == input.Filters.ImpiantoSelezionato.Value).SingleOrDefault();

filtri.ImpiantoSelezionatoString = impianto.Impianto + " - " + impianto.NomeMacchina;
}


StiReport report = new StiReport();
report.Load(Server.MapPath("~/Content/Report/ReportLavorazioni.mrt"));

report.RegData("REPORTLavorazioneDTO", input.ListaLavorazioni);
report.RegData("FilterLavorazioniDTO", filtri);
report.Compile();

return report;
}


//get report event for viewer

public ActionResult GetReportLavorazioni()
{
try
{
StiReport report = GetReportViewerFromSession<StiReport>("ReportViewLavorazioni");

if (report == null)
return null;

return StiMvcViewer.GetReportResult(report);
}
catch (Exception ex)
{
return File(Encoding.ASCII.GetBytes(ex.Message), "text/plain");
}
}


//event for viewer

public ActionResult ViewerEvent()
{
return StiMvcViewer.ViewerEventResult();
}


VIEW:

//code in cshtml report view

@Html.Stimulsoft().StiMvcViewer(new StiMvcViewerOptions()
{
Actions =
{
GetReport = "GetReportLavorazioni",
ViewerEvent = "ViewerEvent"
},

Toolbar =
{
Zoom = StiZoomMode.PageWidth
}
})
Lech Kulikowski
Posts: 6247
Joined: Tue Mar 20, 2018 5:34 am

Re: MVC 5 / Stimulsoft 2018.2.1 / Generic error in GDI+

Post by Lech Kulikowski »

Hello,

Please send us a full simple project which we can run and reproduce the issue. Also, please clarify the operation system, browser etc.

Thank you.
Post Reply