Getting Cannot find license 'Aspose.Cells.lic'

Hello all, I have tried a couple of solutions posted before but none of them worked for me. I’m getting Cannot find license 'Aspose.Cells.lic'. on the server but locally it works fine. I’m doing EmbeddedResource for Aspose.Cells.lic and trying to set the license via the code below

Aspose.Cells.License license = new Aspose.Cells.License();
license.SetLicense("Aspose.Cells.lic");

and the license is kept on the root folder but as soon as it gets deployed to the server I get this error.

@mhaseeb1

The error message Cannot find license 'Aspose.Cells.lic' typically indicates that the application is unable to locate the license file on the server, even though it works fine locally. Here are some steps you can take to troubleshoot and resolve this issue:

  1. Check License File Location: Ensure that the license file is deployed to the correct location on the server. The Aspose.Cells library looks for the license file in several locations:

    • The explicit path you provide.
    • The folder containing the Aspose.Cells assembly.
    • The folder containing the calling assembly.
    • The folder containing the entry (startup) assembly.
    • As an embedded resource in the calling assembly.

    If you are using an embedded resource, make sure that the license file is correctly marked as an embedded resource in your project settings.

  2. Use Full Path: Instead of just using the file name, try specifying the full path to the license file in your code. This can help avoid issues related to relative paths that may differ between your local environment and the server.

    Example:

    Aspose.Cells.License license = new Aspose.Cells.License();
    license.setLicense("/full/path/to/Aspose.Cells.lic");
    
  3. Check Application Start Events: If you are using a web application, ensure that the licensing code is executed during the application startup. You can place the licensing code in the Application_Start method in the Global.asax file to ensure it runs when the application starts.

  4. Permissions: Verify that the application has the necessary permissions to access the license file on the server. Sometimes, file access permissions can prevent the application from reading the license file.

  5. Debugging: Add logging to your application to confirm whether the licensing code is being executed and to capture any exceptions that may occur when trying to set the license.

If you continue to experience issues, consider reviewing similar forum posts that discuss licensing problems when deploying to a new server. These posts often provide insights and solutions that may be applicable to your situation.

Sources:
[1]: Licensing - Aspose Documentation
[2]: License File Not Working Anymore - Aspose Documentation

I’m setting the license for Aspose.Pdf.License too, both are at the same location. I don’t get an error for pdf but I get an error for Cells.

@mhaseeb1
If you can find the license file through the relative directory, you can read the license into the stream object and directly set the license through the stream object. Please refer to the following example code.

 //Instantiate an instance of license and set the license through a stream

Aspose.Cells.License license = new Aspose.Cells.License();

license.SetLicense(myStream);

Hope helps a bit.

Thanks for commenting, I want to package it with the application via EmbeddedResource

@mhaseeb1
Please refer to the following example code to obtain the license stream object from embedded resources, and then set the license.

string path = "Aspose.Cells.lic";
System.IO.Stream stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(path);

//Instantiate an instance of license and set the license through a stream
Aspose.Cells.License license = new Aspose.Cells.License();
license.SetLicense(stream);

Hope helps a bit.

Thank you for replying. I will test your suggested way but I wonder why the simplest way shared in docs is not working.

@mhaseeb1
We will further investigate this issue. Different environments and configurations can lead to different results. Would you like to provide more detailed information? Including but not limited to sample projects, server environments, and more output log information. We will check it soon.

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-57396

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.

@mhaseeb1 ,

We have made some improvements for the license file loading in Aspose.Cells for .Net 25.2(Download | Nuget). Could you please try it on your side?