已更新 2024年10月20日
在 web.config 中設置 IronOCR 授權
This article was translated from English: Does it need improvement?
TranslatedView the article in English
The problem has been resolved as of IronZIP version 2024.3.3.
Exception: Unhandled exception. IronSoftware.Exceptions.LicensingException: IronZip must be licensed for development.
對於較舊的 IronZip 版本,特別是那些在版本之前發布的2024.3.3,已知存在授權問題於:
- ASP.NET 專案
.NET Framework 版本 >= 4.6.2
儲存在
Web.config
檔案中的金鑰不會被產品檢索和使用。
變通方法
要解決此問題,建議在程式碼中使用 ConfigurationManager 從 Web.config
文件中檢索授權密鑰,然後將其應用於 License.LicenseKey 屬性。
範例:
<configuration>
...
<appSettings>
<add key="IronZip.LicenseKey" value="IRONZIP.MYLICENSE.KEY.1EF01"/>
</appSettings>
...
</configuration>
XML
有了上面提供的 XML 檔案,我們可以使用 ConfigurationManager 來取得授權金鑰的值,並傳遞給 IronZip.License.LicenseKey 屬性。
using System.Configuration;
string licenseKey = ConfigurationManager.AppSettings ["IronZip.LicenseKey"];
IronZip.License.LicenseKey = licenseKey;
using System.Configuration;
string licenseKey = ConfigurationManager.AppSettings ["IronZip.LicenseKey"];
IronZip.License.LicenseKey = licenseKey;
Imports System.Configuration
Private licenseKey As String = ConfigurationManager.AppSettings ("IronZip.LicenseKey")
IronZip.License.LicenseKey = licenseKey
$vbLabelText $csharpLabel