Set "Aspose.Cells.lic" file as an embedded resource in .NET

I have a temporary license for Aspose.Cells, and I’ve included it as an embedded resource in my project (see attached screenshot).

In my application, I initialize that license like this:

namespace Vbs.Isfa.Business.Import {
public class ImportFileValidator {


public ImportFileValidator(PruefungsSessionManager pruefungsSessionManager) {
// Instantiate the License class
License license = new License();

// Pass only the name of the license file embedded in the assembly
license.SetLicense(“Aspose.Cells.lic”);
}
}
}

However, that doesn’t seem to work - I still get the extra worksheet with the “This was created with a trial of Aspose.Cells” warning and all.

How do I need to reference the “Aspose.Cells.lic” file?

* like I did - just the file name?
* with the full assembly-level hierarchy, e.g.

license.SetLicense(“Vbs.Isfa.Business.License.Aspose.Cells.lic”);

* something else entirely?

I’d really prefer to have the *.lic file as an embedded resource - not a “on-disk” file

Hi Marc,


Thank you for contacting Aspose support.

I have evaluated the presented scenario while using the latest release of Aspose.Cells for .NET 9.0.1 and an embedded license of my own. I am afraid, I am not able to observe problem with any of the snippets shared at the bottom of this post. In order to further troubleshoot this case, I would request you to perform the following tests.

  • After setting the license in your application, please check if the license has been set properly by using the Workbook.IsLicensed property. If the aforementioned property returns false that either means that the statements to set the license have not been executed or the License.SetLicense method has not thrown any exception (or exception was not captured).
  • If the License.SetLicense has thrown any exception then please share the complete error details for further investigation.
  • Please give a try to the latest version of Aspose.Cells for .NET 9.0.1 (attached).

In case you are still not able to figure out the problem cause, please share an executable sample application (along with all dependencies). Please remove the license file from the sample application because Aspose policies do not allow to share licenses in forums. You can send the license file separately using the approach mentioned here.

Here are the code snippets that I have tried on my side.

C#

Aspose.Cells.License l = new Aspose.Cells.License();
using (Stream stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(“.Aspose.Total.lic”))
{
l.SetLicense(stream);
}


Aspose.Cells.License clic = new AsposeCells.License();
clic.SetLicense(“Aspose.Total.lic”);

Sorry - my bad - the call to “license.SetLicense()” wasn’t called in all cases in my code. Once I made sure the call really happened, everything worked out fine.

Is there any harm in making that call multiple times?

Hi Marc,


First of all, it is good to know that you are able to resolve the problem. Secondly, the API requires to set the license once per every application life cycle. Setting the license multiple times will not effect the API behaviour however, it would be waste of processing.