Runtime error using Aspose.Cells under Mono 4.2.1/4.3.2

I'm getting an abort under Mono 4.2.1 (4.2.1.102/6dd2d0d)

"mini-generic-sharic.c:830, condition 'oti' not met". I believe this is due to the SmartAssembly obfuscation producing an invalid assembly.

The assembly is compiled as a .NET 4.5.2 project in Visual Studio, with the binary then moved to an Ubuntu box where the abort occurs. This occurs with version 8.4.0.0 (I do not have a more recent version). This does not reproduce when compiling with mcs.

To reproduce:
using System;
using System.IO;
using System.Text;
using Aspose.Cells;

namespace Bug
{
public class Program
{
public static void Main(string[] args)
{
const string text =
@"<?xml version=""1.0"" encoding=""utf-8""?>

";
new License().SetLicense(new MemoryStream(Encoding.UTF8.GetBytes(text)));
Workbook workbook = new Workbook();
var y = workbook.Worksheets[0].Cells.Rows.Count;
}
}
}

The problem is the generic instantiation of Aspose.Cells.CollectionBase
Tested under Mono 4.2.1 (latest stable) and 4.3.2 (master branch as of yesterday)

Hi Tony,


Thank you for contacting Aspose support.

I have evaluated your presented scenario by referencing Aspose.Cells.dll (8.4.0 & 8.6.3) directly in a MonoDevelop project and compiled the code against Mono Runtime 3.2.8 without observing any problems. I am now in the process of upgrading the Mono Runtime to 4.2.1 (stable) to give this scenario another try. In the meanwhile, I request you to try against Aspose.Cells for .NET 8.6.3, which is the most latest major release at the moment. In case the problem persists with latest release as well then please share complete stack trace so we could discuss this matter with the product team as well.

The assembly is compiled as a .NET 4.5.2 project in Visual Studio, with the binary then moved to an Ubuntu box where the abort occurs.

Moreover, please elaborate your comments as quoted above. What I understand that you have built a custom assembly, based on Aspose.Cells for .NET API, and have referenced it in Mono. If I am correct, please provide us an executable sample application along with its all dependencies so we could execute the complete process on our side. In case I am wrong in my understanding then please elaborate for investigation purposes.

So the project is a Visual Studio project, which is compiled on Windows, with the .exe moved onto Linux to run under Mono.


The attached file is a .zip which contains an exe, which I have renamed to .zip.docx so that it is not blocked. Place Aspose.Cells.dll in the same directory (8.4.0.0). I’ll try a newer version on Monday.

The source for that program is the same as shown above, except I added some WriteLines() to show where the exception is being thrown.

Hi Tony,


Thank you for sharing the executable. I will give it a try on my side, however, it would be appropriate that you should also share the sample project that created the executable. This is because we need to pass that on to the product team (if applicable) for further investigation.

Please note, community server allows to upload archives in ZIP format so you can upload it directly without changing the extension.

Hi again,


This is to update you that I have executed some tests against Mono 4.2.1 (Ubuntu 15.10) using your provided executable as well as some compiled on my machine (Windows 10 x64) with Aspose.Cells for .NET 8.4.0 & 8.6.3. Please find below the test details and their results.

  1. AsposeBug.exe: It generated the error “Unhandled Exception:System.TypeLoadException: Could not load type ‘Aspose.Cells.CollectionBase1' from assembly 'Aspose.Cells, Version=7.6.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56'.[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeLoadException: Could not load type 'Aspose.Cells.CollectionBase1’ from assembly ‘Aspose.Cells, Version=7.6.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56’.” for Aspose.Cells 8.4.0 & 8.63. It appears you have compiled the executable targeting Aspose.Cells 7.6.0. Could you please confirm?
  2. MonoTester_Cells_2.0.exe (compiled against .NET Framework 2.0): Executed without showing any error, however, mono selected the default framework 4.0 as 2.0 was not available.
  3. MonoTester_Cells_4.5.2.exe (compiled against .NET Framework 4.5.2): Executed fine with expected results.

Following is the code for case 2 & 3 whereas the executables are attached in an archive to this post.

C#

Console.WriteLine(“This is a simple cells program compiled on .NET Framework 4.5.2”);
Console.WriteLine(Aspose.Cells.CellsHelper.GetVersion());
var book = new Aspose.Cells.Workbook();
var sheet = book.Worksheets[0];
var cells = sheet.Cells;
cells[“a1”].PutValue(“Hello”);
Console.WriteLine(cells.Rows.Count);
book.Save(“output_” + Aspose.Cells.CellsHelper.GetVersion() + “.xlsx”);
Console.ReadKey();

As discussed earlier, please provide the sample application (along with its dependencies) so we could perform more tests. Please also give a try to the latest version (download link shared earlier) and feed us back with your results against latest revision 8.6.3.

Attached is a .exe and .dll that, together, about under Mono. Place in the working directory of that .exe a “license.txt” file containing a valid Aspose license.


The problem only manifests if the runtime version of the Aspose.Cells binary does not match that which the assembly was compiled against. (this is not a problem under .NET or usually under Mono). We have rectified the issue on our end however are still curious as to why this is an issue under Mono under the circumstances I described.

Hi Tony,


It is good to know that you are able to resolve the problem. Regarding the root cause, I am afraid, I cannot comment as I am not able to replicate this issue on my side while using Aspose.Cells for .NET 8.4.0 or 8.6.3 with sample projects of my own. However, I suspect that you have the reference property Specific Version set to true in Visual Studio project which could be causing the problem as shared in my previous response (please check attached snapshot). Moreover, if you run the executable from my previous response against Aspose.Cells for .NET 8.4.0, you should receive expected results without any error.

Babar Raza,

Did you try running the latest attachment I sent?
I do not think Specific Version is the cause, as the assembly “succeeds” in loading & setting the license, before bringing down the framework.

http://i.imgur.com/nUP5y7Y.png
This callstack shows that the program successfully makes creates a Workbook, and crashes only later.

Hi Tony,


Yes, I have executed the recently shared exe, and I am able to see the abort error. However, I am not getting any such error with the executables generated from my own sample projects targeting Aspose.Cells for .NET 8.6.3 & .NET Framework 4.5.2. That is the reason I am not able to further investigate the matter nor create a ticket for the product team in this regard because you haven’t share the sample project that created the exe that showed the problem. Please share it here so we could conduct further tests. Moreover, you also haven’t shared the results against the latest build of the API (8.6.3).

That said, you have mentioned you are able to resolve the problem on your side, could you please provide details? Please also test the executables (provided in debug.zip earlier) and share your feedback.