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

Free Support Forum - aspose.com

Calling Chart.ToImage through a CLR compatible C++ DLL throws System.ArithmeticException

Hi

We’re having issues when calling Aspose.Cell in our application through a CLR wrapper in some contexts

When generating a chart the call to Aspose.Cells.Charts.Chart.ToImage generates the following exception

Unhandled Exception: System.ArithmeticException: Overflow or underflow in the arithmetic operation.

at Aspose.Cells.Charts.Chart.ToImage(Stream stream, ImageOrPrintOptions options)

More specifically we have a GUI application built using C++ Builder XE3 from Embarcadero, which then calls a MSVC C/C++ library that then call a CLR wrapper which handles all the calls to Aspose

I’ve reproduced the issue in a set of simplified standalone applications and libraries, in the attached zip file.

The workflow is
1- Project1.exe (the C++ Builder project)
2- AposeCLRLib.dll (a Visual Studio C++ project that is CLR compatible and compiled using stdcall calling convention that exports 1 function and uses the next item)
3- AposeLib.dll (A .NET library that acts as a wrapper and calls the Aspose libary)

I’m not sure where the issue is exactly but I’m hoping that with that information you can reproduce the issue and either fix the issue or provide more information as to any possible workarounds

Other information I can give you is that usually calling Aspose.Cells.Charts.Chart.ToImage once, catching the exception and then calling it again works for some reason, but it’s not a viable long term solution

Also avoiding Embarcadero projects altogether by calling the CLR dll within other Visual Studio projects works fine but again this is not something I can replace or change.

I’m guessing something is not being initialized properly somewhere but without more information of the root cause of the exception it’s really hard to tell

We use the same sequence with other .NET libraries without issues so I don’t know if Aspose requires something our other libraries don’t or if I just missed something along the way.

Thank you for your help

Hi,


Thanks for your posting and using Aspose.Cells.

Please download and try the latest version: Aspose.Cells for .NET v16.10.8.0 it should fix your issue. Let us know your feedback.

I have tested your issue with the latest version and generated the chart successfully. I have attached the output chart image and the screenshot for your reference.

Hi,

I still have the issue when using Aspose.Cells16.10.8.0 you provided

Did you do any other changes beside changing the reference to Aspose?
Did you use the provided Project1.exe file when doing your test?

Here’s what I’m seeing

E:\CompiledAndReadyToRun_v2_UsingAposeCells16.10.8.0>Project1.exe
Loading AsposeCLRLib.dll
GetProcAddress for GenerateChartExtC
Calling aspose CLR lib wrapper
Aspose Version Info: 16.10.8.0

Unhandled Exception: System.ArithmeticException: Overflow or underflow in the arithmetic operation.
at .( , Single , Single , Boolean)
at .( , Int32 , Int32 , Boolean)
at .(? )
at .(? )
at ? ? ?()
at .? ?()
at ? .(Stream , Chart )
at Aspose.Cells.Charts.Chart.ToImage(Stream stream, ImageOrPrintOptions options)
at Aspose.Cells.Charts.Chart.ToImage(String imageFile, ImageOrPrintOptions options)
at AsposeLib.MyChart.GenerateChartData()
at GenerateChartExtC()

I added a call to CellsHelper.GetVersion() to make sure the right version was used, I’ve attached an updated version of the files I initially provided with those adjustments

Thank you

Hi,


Thanks for using Aspose.Cells.

I have re-run your project after adding the main method as shown earlier and by setting the project type from dll to application as shown in the screenshot and rebuilt the project after adding the reference of Aspose.Cells dll and it worked fine and created the chart image. I have attached the project for your reference. Please download it and try at your end. And if you have multiple machines, then please try there too. Please note, I have Visual Studio 2013 which has been installed with all the features.

Another thing is, please try your code in C# Console Application Project and see if you still get some exception so that it could help you sort out this issue and help you know if the problem is occurring because of your machine settings or because of Aspose.Cells dll.

Of course this works, I already said so in my initial post

Luc Charbonneau:

Avoiding Embarcadero projects
altogether by calling the CLR dll within other Visual Studio projects
works fine but again this is not something I can replace or change.


My issue is only when a C++ Builder XE3 project is involed in the call sequence, but since that same sequence is used to call multiple other managed .NET libraries without issues I have no idea why it doesn’t work with Aspose.Cell

To reproduce the issue the project in “EmbarcaderoRadStudioXE3Project” must be used (or the resulting Project1.exe)

Hi,


Thanks for your posting and using Aspose.Cells.

We were able to see the error but we are not sure if the error is directly or indirectly related to Aspose.Cells or if the error is related to Aspose.Cells at all.

We have logged this issue in our database for product team investigation. We will look into it and fix this issue if possible. Once, there is some fix or other news for you, we will update you asap.

This issue has been logged as CELLSNET-44893.

Hi,

Thanks for using Aspose.Cells.

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

It works with that new version thank you

Hi,

Thanks for your feedback and using Aspose.Cells.

It is good to know that your issue is resolved with the latest fix. Let us know if you encounter any other issue, we will be glad to look into it and help you further.

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


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