Generic error occured in GDI +

Hi,

We have an error using Aspose BarCode save method (in red below) : “System.Runtime.InteropServices.ExternalException (0x80004005): A generic error occurred in GDI+”.
This errors occurs only on one of our production server.
It first happened after a reboot of the server.
Restarting the application pool solve the problem for a moment (some hours or days) but it always comes back.

Here is some information about our production environment :

  • Aspose.BarCode.dll - v5.7.0.0
  • Windows 2012 R2 (x64)
  • .Net Framework v4.0.30319
  • IIS (v8.5.9600.16384) using 64bit application pool with the parameter “Enable 32-bit applications” set to True

Here is the stack trace :

System.Runtime.InteropServices.ExternalException (0x80004005): Une erreur générique s'est produite dans GDI+.

à System.Drawing.Image.Save(Stream stream, ImageCodecInfo encoder, EncoderParameters encoderParams)

à System.Drawing.Image.Save(Stream stream, ImageFormat format)

à Aspose.BarCode.BarCodeBuilder.Save(Stream stream, ImageFormat format)

à ePrescription.Socle.Core.Extensions.AsposeCodeBarExtensions.ToBarCode(Object obj)

Here is our code :

public static MemoryStream ToBarCode(this object obj)

{

if (string.IsNullOrEmpty(obj.ToString()))

throw new ArgumentNullException("obj");


MemoryStream memoryStream = new System.IO.MemoryStream();

BarCodeBuilder barCodeBuilder = new BarCodeBuilder();


barCodeBuilder.CodeText = obj.ToString();

barCodeBuilder.SymbologyType = Symbology.Code128;

barCodeBuilder.xDimension = 0.1f;

barCodeBuilder.Margins = new MarginsF(0, 0, 0, 0);

barCodeBuilder.BarHeight = 4f;

barCodeBuilder.ImageQuality = ImageQualityMode.Default;

barCodeBuilder.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SystemDefault;

barCodeBuilder.Save(memoryStream, ImageFormat.Png);


return memoryStream;

}

In our case, the obj parameter is a string (example : “10501893”).

We already saw the thread in the forum : A generic error occurred in GDI+ in ASPOSE.BarCode.

But it doesn’t seem relevant in our case because we save in a memory stream (not in a file).

Can you help us on this please?

Regards,

Mickael

Hi,

Thank you for your inquiry and sharing information.

This is to update you that issue needs investigation. The issue has been logged into our system with ID BARCODENET-36377 for investigation. Our product team will look into it. We will update you via this forum thread.

Hi,

This is to update you that we have observed that you are using an old version. It is always recommended to use the latest version. Please download the latest version Aspose.BarCode for .NET 16.11.0 and try to reproduce the issue in your environment. In case of any issue, forward us the details. We will look into it and update you accordingly.