Good day,
we got an issue when configuring margins on excel documents. However, this issue is kind of specific and only happens in the system environment of our customer, so we cannot provide clear steps to reproduce.
To start with, we using Aspose for .Net and have wrapped some functionallity in an own library. The background of this is, that we are then controlling the Aspose lib from our product, which is written in Delphi, using Crosstalk. This in general is not an issue and has worked fine for several years now. However it is kind of relevant, as the access to exceptions is reduced. When an exception is thrown in .Net, it will be reraised in the Delphi program, providing exception class and message. The stack is not accessable. We tried implementing an exception handler in our .Net wrapper which would verbose the stack to the disk, but according to the customer it does not exist. As we are not allowed to remotely access their server system, we are unable to validate this, so we basically do not have the stack.
The issue itself also is kind of obscure. After some time (which is different each time and we could not discover a pattern yet), we are getting System.FormatException with message
Input string was not in a correct format.
This exception is thrown during our call to set the margins on the excel documents. Our code in the wrapping dll is this:
public void SetMargins(double marginTop, double marginRight, double marginBottom, double marginLeft,
double marginHeader = -1, double marginFooter = -1)
{
try
{
_worksheet.PageSetup.TopMargin = marginTop;
_worksheet.PageSetup.RightMargin = marginRight;
_worksheet.PageSetup.BottomMargin = marginBottom;
_worksheet.PageSetup.LeftMargin = marginLeft;
_worksheet.PageSetup.HeaderMargin = marginHeader;
_worksheet.PageSetup.FooterMargin = marginFooter;
}
catch (Exception e)
{
ExceptionLogger.LogExceptionToTemp(e);
throw;
}
}
From screenshots of our software configration and logfiles we know that the params are called with following values:
image.png (2.4 KB)
The values are a bit odd as they are converted from twips to cm with some old legacy code. I never realized this before but now I will optimize this already in next step.
After the exceptions once occured, this happens on every excel document the customer trys to open (other office formats still can be processed correctly), until the service has been restarted. Then it works ‘for a while’ until it starts happening again.
We also have confirmed, that setting those margins on all documents is not an issue itself in general as we had been able to once process all documents with the code.
As they are the only customer with this issue and we cannot reproduce it locally or discover any pattern/cause for the problem it very likely much be related to their system in some way or due to unknown side effects, which we do not understand yet.
After we disabled margins, the error also does not happen any more in over two weeks now (before, the service had to be restarted multiple times a day due to the issue), so it is very likely confirmed, it must be related to the margins in some way.
The software runs on a Windows Server 2016 Standard Edition with German locale (as far as we know).
I am aware this might be a difficult issue to answer, but maybe you know any similar issues which could have been resolved or maybe can discover potential errors in the Aspose code, which may cause such a FormatException.
I would appreciate if you can provide some feedback to this, kind of very special, issue.
Kind Regards,
Daniel