Is License.IsLicensed Method Planned to Remove?

I see warning message, that after v19.12 method will be removed. See attached image.
But in License class in Aspose Slide doesn’t has any else methods, properties which I can use for check license, it was loaded and loaded successfully.

Could you clarify how I can check it, don’t use IsLicensed method?

Aspose License.jpg (22.0 KB)

@aaksenov,

I like to inform that we are going to remove this in 19.12 version. You may use following sample code on your end to check if license is applied or not.

bool licensed = false;
using (Presentation p = new Presentation())
{
ISlide slide = p.Slides.AddEmptySlide(p.LayoutSlides.GetByType(SlideLayoutType.Blank));
IAutoShape shape = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 10, 10, 200, 100);
shape.TextFrame.Text = “”.PadLeft(500, ‘a’);
licensed = shape.TextFrame.Text.Length == 500;
}

return licensed;

This is very poor solution.
Because for check is license was loaded and loaded successfully will be required create new presentation then create new auto shape and then fill strange text and check strange length of text.
This manupulations will be required todo Instead of current method IsLicensed.

@aaksenov,

Thanks for contacting us. If you loaded the license and no errors occurs, the operation is successful, License is loaded. So there is no need to check it additional via some other methods. We removing IsLicensed for security reasons, this was recommended to our team to comply company’s security policy.

Could you clarify what do you mean “If you loaded the license and no errors occurs, the operation is successful”.

Because SetLicense is void method, it doesn’t return anyting, see declaration of License class below.

namespace Aspose.Slides
{
public class License : ILicense
{
public bool IsLicensed();
public void ResetLicense();
public void SetLicense(string licenseName);
public void SetLicense(Stream stream);
}
}

@aaksenov,

You need to call license in try catch block and handle license related exceptions. If license is not loaded properly, exception will be thrown that you need to handle.

Can you please give an example? What do you mean by “call license”? In order to avoid overhead, I want to call “SetLicense” only once, thus I need to check “IsLicensed”. How else can this be done without incurring large amounts of overhead (like your proposal to create shapes etc.)?

@roryappersonlitera,
Welcome to our community! Thank you for your questions.

You should check if the license is valid as shown below:

try
{
    new License().SetLicense(licenseFilePath);
}
catch (Exception e)
{
    // handle the exception here
}

Documents: Licensing
API Reference: License Class