判断License是否加载成功
Contents
[
Hide
]
Aspose.Cells提供工作簿.IsLicensed可用于确定许可证是否成功加载的属性。如果您在设置许可证之前访问此属性,它将返回错误的如果您在设置许可后调用此属性,它将返回真的表示许可证已成功加载。
C# 判断License是否加载成功的代码
以下代码访问工作簿.IsLicensed设置许可证之前的财产,它返回错误的.然后它加载许可证并再次访问现在返回的属性真的.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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