Free Support Forum - aspose.com

SetLicense from stream

Hi,
i am trying to do something like this:

Aspose.Words.License license = new Aspose.Words.License()

MemoryStream aspLic = new MemoryStream();

string asposeLic = “<?xml version=\"1.0\" encoding=\"utf-8\"?>LicensedToLicenseTypeLicenseNoteOrderIDOEMAspose.Words for .NETEnterpriseSerialNumberSubscriptionExpiryLicenseVersionSignature”;

StreamWriter sw = new StreamWriter(aspLic, Encoding.UTF8);
sw.WriteLine(asposeLic);
sw.Flush();
license.SetLicense(aspLic);


After SetLicense i am getting XmlException “Root element is missing”. What i am doing wrong?
Thanks.

p.s. sorry for my bad english

Hi

Thanks for your request. I think, you should simply set position of the stream to zero. Please see the following code:

Aspose.Words.License license = new Aspose.Words.License()

MemoryStream aspLic = new MemoryStream();

string asposeLic = "<?xml version=\"1.0\" encoding=\"utf-8\"?>LicensedToLicenseTypeLicenseNoteOrderIDOEMAspose.Words for .NETEnterpriseSerialNumberSubscriptionExpiryLicenseVersionSignature";

StreamWriter sw = new StreamWriter(aspLic, Encoding.UTF8);

sw.WriteLine(asposeLic);

sw.Flush();

aspLic.Position = 0;

license.SetLicense(aspLic);

Best regards,

thanks! stupid error(