Aspose.Cells hangs

Hi,

I have a use case where Aspose.Cells hangs.
This issue is demonstrated in the attached unit test.

  • Download and extract: https://ufile.io/2ad46
  • Open sln in VS 2017 - Framework-Mini.sln
  • Let VS restore nuget packages
  • Build
  • Run Tests in: Tests -> Framework.Tests -> Common.DocumentFormat -> TextReplaceTests.cs
  • TextIsReplacedInExcel (running Aspose.Cells) hangs

Best regards

@lars.olsson

Thanks for using Aspose APIs.

Please provide the isolated test case. Do not provide all the non-Aspose.Cells related and business related files. We could not execute your complex code because of build errors.

We only found the following relevant code. Please provide this code in runnable form or as a console application project so that we could test this issue and replicate it.

Please also let us know if you are using .NET Core or .NET Standard or regular .NET Framework Aspose.Cells DLLs.

C#

[Test]
public void TextIsReplacedInExcel()
{
	const string cellWithFirstValue = "A1";
	const string cellWithBothValues = "B2";
	const string cellWithSecondValue = "C3";

	var workbook = new Workbook();
	var worksheetCells = workbook.Worksheets[0].Cells;
	worksheetCells[cellWithFirstValue].PutValue(FirstTextToReplace);
	worksheetCells[cellWithBothValues].PutValue($"{FirstTextToReplace} equals {SecondTextToReplace}");
	worksheetCells[cellWithSecondValue].PutValue(SecondTextToReplace);

	var workbookXlsxStream = new MemoryStream();
	workbook.Save(workbookXlsxStream, Aspose.Cells.SaveFormat.Xlsx);
	var workbookXlsxStreamReplaced = this.textReplacer.Replace(workbookXlsxStream, SupportedFormat.Xlsx, this.pattern, MatchToStringValue);
	var replacedWorkbook = new Workbook(workbookXlsxStreamReplaced);
	var replacedWorksheetCells = replacedWorkbook.Worksheets[0].Cells;
	Assert.AreEqual(ReplacementText, replacedWorksheetCells[cellWithFirstValue].StringValue);
	Assert.AreEqual("chimpans equals chimpans", replacedWorksheetCells[cellWithBothValues].StringValue);
	Assert.AreEqual(ReplacementText, replacedWorksheetCells[cellWithSecondValue].StringValue);
}

The test project runs .net 4.7.1 and library which contains the Aspose.Cells code targets netstandard 2.0 and runs Aspose.Cells 18.3.0.0.
Then I debug, I get a “System.AccessViolationException - Attempted to read or write protected memory. This is often an indication that other memory is corrupt”.

Is this a known issue?

@lars.olsson

We think, the normal version should work fine and since netstanard is quite new, it could have issues. Please provide us the simple console application project as requested earlier so that we replicate and log the issue and fix it consequently.

Screenshot - Build Errors:

Hi again,

Attached is the simplest possible solution we could create that reproduces the issue. It’s a console app that uses a .NET Standard 2.0 class, which in turn uses Aspose.Cells. The console app consistently crashes with the message “An unhandled exception of type ‘System.ExecutionEngineException’ occurred in Unknown Module. occurred”.

Hopefully this can help in tracking down the problem!

AsposeCellsMemoryBug.zip (6.0 KB)

@lars.olsson

Thanks for using Aspose APIs.

Your issue has been fixed in 18.4. Just change your package from 18.3 to 18.4 and rebuild the project and it will run fine. Let us know if you face any issue, we will look into it and help you asap.

Download Link: