Error Setting License

I’m generating and Excel document in my Blazor app. The following code works perfectly in debug mode, however, when I publish it using AOT, I get the following error:

    private void SetLicense()
    {
        Assembly assembly = Assembly.GetExecutingAssembly();
        string resourceName = "Data.Aspose.Total.lic";

        using Stream stream = assembly.GetManifestResourceStream(resourceName);

        License lic = new();
        lic.SetLicense(stream);
    }

I’ve also tried setting the license using a stream reader and get the same error.

string licenseKey = "xxx";
using Stream stream = new MemoryStream(Encoding.Unicode.GetBytes(licenseKey));

License lic = new();
lic.SetLicense(stream);

The error message is:

Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
Unhandled exception rendering component: ArgumentOutOfRange_NeedNonNegNum Arg_ParamName_Name, value
System.ArgumentOutOfRangeException: ArgumentOutOfRange_NeedNonNegNum Arg_ParamName_Name, value
at .(Int32 , Boolean )
at e.e()

How can I resolve this?

@coderdude,

We would appreciate if you could provide us more details (with complete error trace) and a sample application that reproduces the same issue (please exclude the license file from the project archive). Also, please let us know of your complete environment details where it is not working. What .NET Core version (e.g., 2.0/3.0/.NET6.0/.NET7.0) is installed on your server? By the way, we recommend using latest version of Aspose.Cells for .NET v23.5 (Releases | NuGet) which has more enhancements, so kindly try it if you are not already using it.

PS. please zip the project prior attaching.

I’m using .Net 7.0 and Aspose.Cells for .NET v23.5. I have attached a sample project demonstrating the issue. It’s the standard Blazor template with a button labeled “Create File”. If you click on that, it creates an XLSX file using Aspose.Cells and then sends it to the browser (which will make it act as a downloaded document allowing you to open it).

Note that if you load this project and just run it from the debugger (or use dotnet run), it will work just fine. The problem only occurs when you enable Ahead of Time compilation (AOT). I have enabled AOT in the Publishing Profile named “FolderProfile.pubxml”. Just right-click on the “AsposeCells” project in the solution explorer and select “Publish”, then click the Publish button. This will take about 12 minutes to complete. Once this is done, you can use the command-line to navigate to the target location at “bin\release\net7.0\browser-wasm\publish” and run the following commands:

dotnet tool install --global dotnet-serve

dotnet serve

This will start a local server to host the published files (this is necessary as they can’t be executed directly from the file system). Open the site from the port it’s hosted on and click on the “Create File” button and nothing will happen. Press F12 to open the console and see the error.

AsposeCells.zip (327.4 KB)

@coderdude,

Thank you for the provided project. We will investigate it and give feedback soon.

@coderdude,

We need to evaluate and investigate your issue in details. We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): CELLSNET-53412

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

The issues you have found earlier (filed as CELLSNET-53412) have been fixed in this update. This message was posted using Bugs notification tool by johnson.shi