A generic error occurred in GDI+

Technical support for Spire.XLS

Moderators: iceblue support, Flash, Manager

A generic error occurred in GDI+

Postby jmsunseri » Fri Aug 04, 2017 10:25 pm

I'm trying to take a stream of an Excel file and convert it to a PDF a brief snippit of my code is

Code: Select all
using (var gpStream = Utils.GenerateGpReport(connStr, dvrDate))
            using (var stStream = Utils.GenerateStReport(connStr, dvrDate))
            using (var riskPdfStream = GetRiskPdfForDate(config.RiskEmailUserName, config.RiskEmailPassword, config.RiskEmailAddress, riskDate))
            using (var gpPdfStream = new MemoryStream())
            using (var stPdfStream = new MemoryStream())
            using (Workbook gpWorkbook = new Workbook())
            using (Workbook stWorkbook = new Workbook())
            {

                gpWorkbook.LoadFromStream(gpStream);
                log.Info("GP workbook loaded");
                gpWorkbook.SaveToStream(gpPdfStream, FileFormat.PDF);

                stWorkbook.LoadFromStream(stStream);

                log.Debug("ST workbook loaded");

                stWorkbook.SaveToStream(stPdfStream, FileFormat.PDF);


I get this GDI error message randomly. I know there is probably something that causes it to happen in a rational basis but as of yet I can't determine what causes it to happen and can't repeat the problem in any predictable manner. I get the following error when it crashes

Exception: System.Runtime.InteropServices.ExternalException (0x80004005): A generic error occurred in GDI+.
at System.Drawing.Image.Save(Stream stream, ImageCodecInfo encoder, EncoderParameters encoderParams)
at spr350.0()
at Spire.Xls.Core.Spreadsheet.XlsWorkbookShapeData.AddPicture(Image image, ImageFormatType imageFormat, String strPictureName)
at Spire.Xls.Core.Spreadsheet.Shapes.XlsBitmapShape.set_Picture(Image value)
at spr4315.0(XmlReader A_0, XlsBitmapShape A_1, RelationsCollection A_2, String A_3, spr262 A_4, List`1 A_5, Dictionary`2 A_6)
at spr4315.1(XmlReader A_0, XlsBitmapShape A_1, RelationsCollection A_2, String A_3, spr262 A_4, List`1 A_5, Dictionary`2 A_6)
at spr4315.0(XmlReader A_0, XlsWorksheetBase A_1, String A_2, List`1 A_3, Dictionary`2 A_4)
at spr4315.1(XmlReader A_0, XlsWorksheetBase A_1, String A_2, List`1 A_3, Dictionary`2 A_4)
at spr4315.4(XmlReader A_0, XlsWorksheetBase A_1, String A_2, List`1 A_3, Dictionary`2 A_4)
at spr511.0(XlsWorksheetBase A_0, spr5002 A_1, Dictionary`2 A_2)
at spr511.0(XlsWorksheetBase A_0, String A_1, Dictionary`2 A_2)
at spr4315.0(XmlReader A_0, XlsWorksheet A_1, Dictionary`2 A_2)
at spr4315.0(XmlReader A_0, XlsWorksheet A_1, MemoryStream& A_2, String A_3, Dictionary`2 A_4)
at spr511.1(XlsWorksheet A_0, Dictionary`2 A_1)
at Spire.Xls.Core.Spreadsheet.XlsWorksheet.ParseData(Dictionary`2 dictUpdatedSSTIndexes)
at spr4315.0(Dictionary`2 A_0)
at spr262.0(List`1& A_0)
at spr262.1(List`1& A_0)
at spr846.0(Object A_0, Stream A_1, ExcelVersion A_2, ExcelParseOptions A_3)
at spr995.0(Stream A_0, ExcelVersion A_1, ExcelParseOptions A_2)
at Spire.Xls.Workbook.LoadFromStream(Stream stream)
at Crestwood.Dvr.Integrations.DvrIntegration.Run(String configurationFilePath, String archivePath, ILog log, String database)
at Crestwood.Dvr.WebService.Controllers.IntegrationsController.Post(String database, String integration)

I believe I am using version 7.9.0.55040

Thanks for all your help
jmsunseri
 
Posts: 4
Joined: Fri Aug 04, 2017 10:11 pm

Re: A generic error occurred in GDI+

Postby Jane.Bai » Mon Aug 07, 2017 3:02 am

Hello,

Thanks for your inquiry.
Since you were using the free version and there might exist some limitations, I suggest you first downloading the latest Spire.XLS Pack Hotfix Version:7.12.55 to have a try. If the issue still troubles you, please share your sample file as well as the running environment of the project. For the privacy, you could send them to us via email(support@e-iceblue.com).

Sincerely,
Jane
E-iceblue support team
User avatar
Jane.Bai
 
Posts: 345
Joined: Tue Nov 29, 2016 1:47 am

Re: A generic error occurred in GDI+

Postby Jane.Bai » Fri Aug 11, 2017 10:17 am

Hello,

How is your issue now?
Could you please give us some feedback at your convenience?

Sincerely,
Jane
E-iceblue support team
User avatar
Jane.Bai
 
Posts: 345
Joined: Tue Nov 29, 2016 1:47 am

Re: A generic error occurred in GDI+

Postby jmsunseri » Fri Aug 11, 2017 9:40 pm

Sorry it's taking me so long to get back to you. When I removed the version i had in my project and added references to the 4 files Spire.Common, Spire.License, Spire.Pdf, and Spire.XLS manually I got an error message saying "The license key is not valid for this version". I'm using the version available here e-iceblue.com/News/spirexls-71269-enhances-the-performance-of-conversion-excel-to-pdf.html is this not the correct version?
jmsunseri
 
Posts: 4
Joined: Fri Aug 04, 2017 10:11 pm

Re: A generic error occurred in GDI+

Postby Jane.Bai » Mon Aug 14, 2017 2:10 am

Hello,

Thanks for your reply.
To speed up the process, I want to know the following three points.
1. If you do not apply the key, will you still get the exception "A generic error occurred in GDI+" with the new version(Spire.XLS 7.12.69 )?
2. Since we didn't found any purchase record according to your registered account and the related email address, we have no access to your license information. If possible, could you please tell us your purchase email address or share your license file with us(support@e-iceblue.com)?
3. Could you also tell us in which line did the exception("The license key is not valid for this version") occur?
Looking forward to your reply.

Sincerely,
Jane
E-iceblue support team.
User avatar
Jane.Bai
 
Posts: 345
Joined: Tue Nov 29, 2016 1:47 am

Re: A generic error occurred in GDI+

Postby jmsunseri » Mon Aug 14, 2017 3:22 pm

Jane,

I don't believe that's it's going to be possible for me to test if I can get the GDI+ error without applying the key. First I think it will not allow me to proceed in my application without a license using the files that I downloaded from your website. Secondly this GDI+ error occurs so infrequently that I have a lot of difficulty testing it under normal circumstances. I have a process that runs daily and turns out a report. Once or twice a month it will fail with this message. It's making dealing with this problem quite annoying.

I'm not sure that I purchased a license from e-Iceblue as previously I was using this free version available via nuget (see picture below). I don't think I would have any problem getting the funding from my boss for a license for the full version if I could guarantee that this would resolve the problem. It's a very hard thing to do given the infrequency of the problem.

Capture.PNG
Capture.PNG (24.31 KiB) Viewed 141 times


the full exception that I'm getting is as follows
Code: Select all
{
    "Message": "An error has occurred.",
    "ExceptionMessage": "The license key is not valid for this version.",
    "ExceptionType": "System.Exception",
    "StackTrace": "   at Crestwood.Dvr.WebService.Controllers.IntegrationsController.Post(String database, String integration) in C:\\Work\\DVR\\Crestwood.Dvr.WebService-dev\\Crestwood.Dvr.WebService\\Controllers\\IntegrationsController.cs:line 120\r\n   at lambda_method(Closure , Object , Object[] )\r\n   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)\r\n   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Filters.AuthorizationFilterAttribute.<ExecuteAuthorizationFilterAsyncCore>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Filters.AuthorizationFilterAttribute.<ExecuteAuthorizationFilterAsyncCore>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()"
}
jmsunseri
 
Posts: 4
Joined: Fri Aug 04, 2017 10:11 pm

Re: A generic error occurred in GDI+

Postby Jane.Bai » Tue Aug 15, 2017 7:14 am

Hello,

Thanks for your response.
According to the latest exception details you provided, we observed the exception was not thrown by our product. So, could you tell us where was the exception("The license key is not valid for this version") thrown? In which line?
Kindly note the license is used for removing the warning message in the document for commercial version, and it will not bring any bad influence to your project, such as the exception. The key I mentioned in my last reply was the license key in the license file, I asked that because I wanted to make sure if the exception was caused by the license validation. Only when you purchased our product would we send the license file to you, so please don't worry about the license.
Looking forward to your reply.

Sincerely,
Jane
E-iceblue support team
User avatar
Jane.Bai
 
Posts: 345
Joined: Tue Nov 29, 2016 1:47 am

Re: A generic error occurred in GDI+

Postby jmsunseri » Tue Aug 15, 2017 6:28 pm

Thank you for clearing that up. I rebuilt the project and deleted all the previous files before publishing again to the development instance and the job ran successfully. Unfortunately this really doesn't tell me if the updated library will be any better than the old one at this point. I'm going to schedule the job to run every 10 minutes in the hopes that it will cause the job to fail sooner than it would under it's normal schedule. If you have a ticket open please hold on to it for now. I'll be back in touch if the process begins to fail again.
jmsunseri
 
Posts: 4
Joined: Fri Aug 04, 2017 10:11 pm

Re: A generic error occurred in GDI+

Postby Jane.Bai » Wed Aug 16, 2017 8:03 am

Hello,

Glad to hear that.
If the process begins to fail, just come back to us and we will focus on it again.

Sincerely,
Jane
E-iceblue support team
User avatar
Jane.Bai
 
Posts: 345
Joined: Tue Nov 29, 2016 1:47 am


Return to Spire.XLS

Who is online

Users browsing this forum: No registered users and 1 guest