判断License是否加载成功

C# 判断License是否加载成功的代码

以下代码访问工作簿.IsLicensed设置许可证之前的财产,它返回错误的.然后它加载许可证并再次访问现在返回的属性真的.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the License File
string licPath = @"Aspose.Cells.lic";
// Create workbook object before setting a license
Workbook workbook = new Workbook();
// Check if the license is loaded or not. It will return false
Console.WriteLine(workbook.IsLicensed);
try
{
Aspose.Cells.License lic = new Aspose.Cells.License();
lic.SetLicense(licPath);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
// Check if the license is loaded or not. Now it will return true
Console.WriteLine(workbook.IsLicensed);

控制台输出

这是上述示例代码的控制台(调试)输出

False

True