Hi,
This message was posted using Page2Forum from SetLicense Method - Aspose.Words for .NET
Hi,
Ah! I’ve discovered that it throws an InvalidOperationException with a message along the lines of:
Hi
Thanks for your inquiry. Yes, you are right, Aspose.Words throws an exception when you attempt to set an invalid license.
Also, for testing purposes, you might find the following method useful:
///
/// Returns true if the Aspsoe.Words license is set.
///
private static bool IsLicenseSet()
{
// We will insert this text at the beggining of the document.
// If the license set this text will be in the first paragraph,
// if not an evaluation watermark will be in the first paragraph.
const string text = "This is text used to check if the license is set";
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.Write(text);
// Save and optn the document. If Aspose.Words works in evaluation mote it will add a watermark.
using (MemoryStream docStream = new MemoryStream())
{
doc.Save(docStream, SaveFormat.Doc);
docStream.Position = 0;
doc = new Document(docStream);
}
// Check text of the first paragraph.
return (doc.FirstSection.Body.FirstParagraph.ToTxt().Trim() == text);
}
Best regards,