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