Dear aspose team,
I just got the license for the latest aspose total and it seems the way of activating it has changed from what we had before.
Could you please be so kind and help how to activate license once without going over all used products.
internal class AsposeLicenseLoader : IHostedService
{
private static readonly string[] AsposeLicenseProducts =
{
$"{nameof(Aspose)}.{nameof(Aspose.CAD)}.{nameof(Aspose.CAD.License)}, {nameof(Aspose)}.{nameof(Aspose.CAD)}",
$"{nameof(Aspose)}.{nameof(Aspose.Imaging)}.{nameof(Aspose.Imaging.License)}, {nameof(Aspose)}.{nameof(Aspose.Imaging)}",
$"{nameof(Aspose)}.{nameof(Aspose.Font)}.{nameof(Aspose.Font.License)}, {nameof(Aspose)}.{nameof(Aspose.Font)}",
};
private const string _asposeLicense = "here the code is hidden for security reasons";
public AsposeLicenseLoader(ILogger<AsposeLicenseLoader> logger)
{
try
{
using var ms = new MemoryStream(Convert.FromBase64String(_asposeLicense));
using var deflator = new DeflateStream(ms, CompressionMode.Decompress);
using var data = new MemoryStream();
deflator.CopyTo(data);
foreach (var product in AsposeLicenseProducts)
{
data.Position = 0;
var licenseType = Type.GetType(product);
var setLicenseMethod = licenseType?.GetMethod(
nameof(Aspose.Imaging.License.SetLicense),
new[] { typeof(Stream) }
);
if (licenseType == null || setLicenseMethod == null)
return;
var loader = Activator.CreateInstance(licenseType);
setLicenseMethod.Invoke(loader, new[] { data });
}
}
catch (Exception)
{
logger.LogError("Could not load license for extended formats");
}
}
image.png (265.5 KB)