I'm using Aspose to handle PDFs and Word documents. Each time I'm about to do something with a document, I make sure to call this:
Aspose.Pdf.License pdfLicense = new Aspose.Pdf.License();
pdfLicense.SetLicense("Aspose.Total.lic");
Aspose.Words.License wordLicense = new Aspose.Words.License();
wordLicense.SetLicense("Aspose.Total.lic");
The pdfLicense
and wordLicense
variables are never used anywhere, yet Aspose correctly recognises that I do have a valid license. How does this happen? Are the licenses being held in a secret singleton somewhere? If so, does this mean they last for the lifetime of the thread?
As this is being used in a web application, if I run the above code when the application starts up, can I then safely use Aspose throughout my application without worrying about the licensing?
At the moment I'd being more paranoid and running that code at the start of every method that uses Aspose. This works fine - my license is recognised correctly - but it's a bit too "programming-by-coincidence" for me to feel comfortable about it.
(I'm using C# with ASP.NET 3.5, if that makes any difference.)
If you read the product documentation, you will see this line:
You need to set a license before performing any operations with documents. It is only required to set a license once per application (or process).
Hence it is process-centric.