IronWord 授權金鑰在 ASP.NET 配置中
2024年3月19日
已更新 2024年10月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