We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Set Licence Errors when called Second time

I have a code where I set licences for different aspose total products(I am using evaluation licence).

It sets licence the first time I call it but when I call set licecne second time I get an exception
"Root element is missing" I am not sure why calling it second time causes the issue. I am sure the licence file XML is correct.


private void SetLicences()
{
using (Stream licenceStream = "Aspose.Total.lic"))
{
Aspose.Words.License wordLicense = new Aspose.Words.License();
wordLicense.SetLicense(licenceStream); // This works fine

Aspose.Cells.License excelLicence = new Aspose.Cells.License();
excelLicence.SetLicense(licenceStream);\\this errors

Aspose.Pdf.License pdfLicense = new Aspose.Pdf.License();
pdfLicense.SetLicense(licenceStream);
}
}

Hi Helen,


Thank you for contacting support. It is because Aspose.Words SetLicense method reads the license stream and the cursor ended up at the end of the stream. Since nothing left for Aspose.Cells to read. Please modify your code to set cursor at start position each time:

[.NET, C#]
using (Stream licenceStream = “Aspose.Total.lic”))
{
Aspose.Words.License wordLicense = new Aspose.Words.License();
wordLicense.SetLicense(licenceStream); // This works fine

licenceStream.Seek(0, SeekOrigin.Begin);
Aspose.Cells.License excelLicence = new Aspose.Cells.License();
excelLicence.SetLicense(licenceStream);\this errors

licenceStream.Seek(0, SeekOrigin.Begin);
Aspose.Pdf.License pdfLicense = new Aspose.Pdf.License();
pdfLicense.SetLicense(licenceStream);
}

We hope, this helps. Please let us know in case of any ambiguity or questions.

Thanks that worked!