We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

'System.StackOverflowException' in SheetRender.ToImage(0- file)

Hi again,

Thank you for your patience.

Unfortunately, we are unable to replicate the System.StackOverflowException with your provided sample. Although we have observed CellsException: “Arithmetic operation resulted in an overflow” while rendering the worksheet “B2-ProductView” to image with specified PrintArea (A2:AI92). We have logged this problem in our bug tracking system under ticket Id CELLSNET-42649 for further investigation and correction purposes.

In order to investigate the originally posted problem (System.StackOverflowException), we would request you to please share the complete spreadsheet. You may use the same mechanism (via an email) to share any private data with us. Please note, we request for samples to replicate the problem on our end. As soon as the reported problem is fixed, and a release containing the fix is available for public use, we delete all customer shared data. For further assurance, please check EULA for NDA (clause 8).

Please feel free to write back in case you have any concerns.

Good, that you were able to create the one error – I also had this error when reducing the number of worksheets down to just the 2. I believe that if this issue is fixed there is a good chance it will also resolve the other, worse error of the StackOverflowException.

I am working with out team to send you the full worksheet which creates the primary issue.
Thanks for the prompt attention.

Hi Dan,

Thank you for sending the complete spreadsheet for our testing. Unfortunately, we are unable to replicate the “StackOverflowException” using the following piece of source code. Instead, the code is producing the image as per expectation. We will send the image via a private message.


Workbook wb = new Workbook(myDir + “Product Capability Burndown MER 5.1.14_DAN.xlsm”);
Worksheet ws = wb.Worksheets[“B2-ProductView”];
PageSetup ps = ws.PageSetup;
ps.LeftMargin = 0;
ps.RightMargin = 0;
ps.TopMargin = 0;
ps.BottomMargin = 0;
ps.CenterHorizontally = true;
ps.CenterVertically = true;
ps.PrintArea = “A2:AI92”;

//Define ImageOrPrintOptions
ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();
//Specify the image format
imgOptions.ImageFormat = System.Drawing.Imaging.ImageFormat.Png;
//Only one page for the whole sheet would be rendered
// – OBSOLETE imgOptions.IsImageFitToPage = false;
imgOptions.OnePagePerSheet = true;
imgOptions.IsImageFitToPage = true;
imgOptions.OnlyArea = true;
//Render the sheet with respect to specified image/print options
SheetRender sr = new SheetRender(ws, imgOptions);
//Render the image for the sheet
sr.ToImage(0, myDir + “output.png”); // CODE DIES HERE.
catch (Exception e)

Please note, we have evaluated the presented scenario while using the latest version of Aspose.Cells for .NET 8.0.2 (assembly from net2.0 folder), target framework 2.0 on Windows 7 Home Premium 64-bit platform.

We would request you to give the latest version another try using the code snippet provided in this post. In case the problem persists, please provide us the environment details so we could simulate your environment to re-evaluate the problem on our end. Please note, we are interested in the following information,

  • Operating System version
  • Operating System Architecture (32bit/64bit)
  • Target Framework
  • Application Type

That is odd that you are not having the same issue.

I was originally using Aspose.Cells for .Net\Bin\net3.5\Aspose.Cells.dll
I changed to Aspose.Cells for .Net\Bin\net2.0\Aspose.Cells.dll and still have the problem.
The Runtime Version is v2.0.50727 and the Version is (as shown within the Properties of the Reference section of the solution.

I am running Windows 7 Home Premium 64-Bit.
The Target Framework is currently set to .Net Framework 4.5 (Do I need to change this to 2.0? - It will create some issues if I do.

Also, is there a reason to use the net2.0 versus the net3.5 version?

I would like to also add…

I was looking at the code you replied with. I saw that you added wb.CalculateFormula();

When I added this call, I got the Stack Exception here. I also tried the call with the ignoreError flag set to true, same problem.

Hi Dan,

We are already using the same environment as of yours but still we are unable to replicate the exception on our end. Moreover, we have tested by changing the target framework to 2.0, 3.0, 3.5, 4.5 & 4.5.1, and while using the assemblies from different folders of Aspose.Cells installation directory. Unfortunately, the exception didn’t occur even once otherwise we would have logged the problem in our bug tracking system providing the stack trace.

Regarding the different Aspose.Cells assemblies, as mentioned in the readme.txt provided with Aspose.Cells for .NET package, if you are targeting .NET 3.5 or 4.0, you should be using the assembly from the net3.5 folder. For all other frameworks with exception of Client Profile, you should use the assembly from net2.0 folder. I have attached the aforesaid readme.txt with this post for your reference.

Please provide the complete stack trace of the exception that you are getting on your end so we could try to troubleshoot the problem based on the stack trace. Please also confirm that you are loading the same spreadsheet that you have provided to us.

I have verified each of my assemblies. I went back and created a single page aspx file with a single image and the call to the function above. When I use the wb.CalculateFormula I get the “unhandled exception of type ‘System.StackOverflowException’ occured in Aspose.Cells.dll”

The troubleshooting steps I get mentioned are looking for an infinite loop or infinite recursion.

There is no way to retrieve the stack trace since the error effectively wipes out the stack. Commenting out the wb.CalculateFormula gets me to the sr.ToImage call where it also dies.

Is there any other dependent libraries that could interfere? Since I am relatively new (very new actually) to the .Net development, is there a way to get more information out of the failed stack overflow result?

Hi Dan,

Thank you for your continues support.

We are able to observe the System.StackOverflowException while using the previously provided code snippet in a simple ASP.NET application. We have logged this problem in our bug tracking system under ticket Id CELLSNET-42651 for further investigation and correction purposes. Please spare us little time to properly analyze the problem cause, and to provide a fix (if applicable) at earliest. In the meanwhile, we will keep you posted with updates in this regard.

Please note, earlier we were testing the presented scenario on a console application that didn’t allow us to observe the System.StackOverflowException. Now we can see the said exception at Workbook.Calculate as well as the SheetRender.ToImage methods, and same has been logged in aforesaid ticket.

Please accept our sincere apologies for the inconvenience caused to you.

I’m glad to hear you were able to repeat the issue. Thanks for continuing to look into this. Looking forward to the results.

Is there any estimate on when a fix for this issue will be resolved?

Additionally, is there an escalation process?
Thanks in advance.

Hi Dan,

Thank you for writing back.

Unfortunately, both ticket attached to this thread are currently pending for analysis and are in the queue with other tasks. We have logged a note for the concerned team member to share the insight of the problems at earliest, and if possible also provide the estimated release schedule for the fix. As soon as we receive any news, we will post here for your kind reference.

Regarding your other question, as you are availing the free support therefore any issue raised by you will be added to a queue that follows the “First Come, First Serve” paradigm. If you wish to escalate the process, you may have to consider any of the paid support subscriptions. Please check out the details for different support options.

We are not averse to paying for priority or better support. Unfortunately this current issue is a complete show stopper for us and does not allow us to proceed. We had purchased another component only to find later it could not do what we needed. The Aspose solution actually comes very close with the exception of this Stack Overflow. This is preventing us from purchasing OEM licenses.

Any help to at least have an indication on this issue or some assurance that if this cannot be fixed in some “reasonable” time, then some type of other arrangements (regarding purchase) can be made.

Please let me know your thoughts,

Thanks for the great support so far,

Hi Dan,

We have provided the details of the different support options upon your request as you wished to escalate the process of resolving the mentioned ticket.

In reference to StackOverflowException problem, I am afraid, we wont be able to provide an estimated release schedule for the fix unless we have properly analyzed the problem. So far we haven’t heard from the core development team on this matter so I believe the mentioned ticket is in analysis phase at the moment. Please spare us little time, and we will soon get back to you with more updates in this regard.


Thanks for your using Aspose.Cells.

Please download and try the latest fix: Aspose.Cells for .NET v8.0.2.2 and let us know your feedback.


Thanks for using Aspose.Cells.

After further investigation of your issue, we found and think the issue “CELLSNET-42651” may be caused by the fact that the default stack size of IIS is too small (256k only). It is not the issue of our component but due to too much small default stack size of IIS. .Please see the sample code for your reference and try to change your code accordingly:


private HttpPostedFileBase file;


public ActionResult Index(HttpPostedFileBase file, string mode)


this.file = file;

Thread t = new Thread(Calc, 1048576);



return null;


private void Calc()


if (file != null && file.ContentLength > 0)


var wbkMain = new Workbook(file.InputStream);




Hopefully it will fix your issue.

Thank you.


Thank you for the update. I have downloaded the version and I am trying to get the snippet of code that you provided working. Unfortunately I am pretty new to .Net and C#. I have attempted to add the System.Web.Mvc.ActionResult and for some reason, it still does not resolve the ActionResult.

Also, the “file” in the application case for the code that is being processed is actually a file that exists on the server. Would there be a need to pass the file in?

From the code where I am processing the workbook, is there an easy way to invoke the thread setup method you defined? For example, is there a different way for me to invoke the Index? I assume from my normal method I invoke the Calc() method, just trying to understand how the thread (and stack) get invoked.

Thanks for your time.


I downloaded this latest fix. Is this an update to the ToIimage issue? If so, unfortunately it still has the same exception occur. I am currently working to get the Recalculate to use the thread changes recommended by the other post due to the stack size, but having no luck as of yet.

I will keep you informed if anything changes.

Hello, one more time… SUCCESS.

I was able to setup the threading and invoke the Calc method to perform the Workbook.CalculateFormula.

Success !!! There are some minor rendering issues I see but at least we are now rendering the majority and more importantly, not crashing.

Thank you for the continued support!

Hi Dan,

Thanks for your feedback and using Aspose.Cells.

It is good to know that you met with success in sorting out this issue after increasing the default stack size. Let us know if you are still encountering any issue, we will be glad to look into it and help you further.

The issues you have found earlier (filed as CELLSNET-42649) have been fixed in this update.

This message was posted using Notification2Forum from Downloads module by Aspose Notifier.