在 web.config 中设置 IronBarcode 许可证
2024年三月20日
更新 2024年十二月17日
This article was translated from English: Does it need improvement?
TranslatedView the article in English
这个问题已在IronBarcode的2024.3.2版本中解决。
Exception: Unhandled exception. IronSoftware.Exceptions.LicensingException: IronBarcode must be licensed for development.
对于较旧版本的IronBarcode,特别是版本2023.4.1到2024.3.2之间,已知存在许可问题:
- ASP.NET 项目
.NET Framework 版本 >= 4.6.2
存储在
Web.config
文件中的密钥不会被产品拾取和使用。
变通方法
为了解决此问题,建议在代码中使用ConfigurationManager从Web.config
文件中检索许可证密钥,然后将其应用于License.LicenseKey属性。
示例:
<configuration>
...
<appSettings>
<add key="IronBarCode.LicenseKey" value="IRONBARCODE-MYLICENSE-KEY-1EF01"/>
</appSettings>
...
</configuration>
XML
使用上面提供的XML文件,我们可以使用ConfigurationManager来检索许可证密钥值,并将其传递给IronBarCode.License.LicenseKey属性。
using System.Configuration;
string licenseKey = ConfigurationManager.AppSettings ["IronBarCode.LicenseKey"];
IronBarCode.License.LicenseKey = licenseKey;
using System.Configuration;
string licenseKey = ConfigurationManager.AppSettings ["IronBarCode.LicenseKey"];
IronBarCode.License.LicenseKey = licenseKey;
Imports System.Configuration
Private licenseKey As String = ConfigurationManager.AppSettings ("IronBarCode.LicenseKey")
IronBarCode.License.LicenseKey = licenseKey
$vbLabelText $csharpLabel