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