web.co/nfig 中的 IronBarcode 授權設定
This article was translated from English: Does it need improvement?
Translated
View 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.co/nfig 檔案中的金鑰,產品將不會讀取並使用。
解決方案
為解決此問題,建議在程式碼中使用 ConfigurationManager 從 Web.co/nfig 檔案中取得授權金鑰,然後將其套用至 License.LicenseKey 屬性。
範例:
<configuration>
...
<appSettings>
<add key="IronBarCode.LicenseKey" value="IRONBARCODE-MYLICENSE-KEY-1EF01"/>
</appSettings>
...
</configuration>
<configuration>
...
<appSettings>
<add key="IronBarCode.LicenseKey" value="IRONBARCODE-MYLICENSE-KEY-1EF01"/>
</appSettings>
...
</configuration>
XML
透過上述提供的 XML 檔案,我們可以使用 ConfigurationManager 擷取授權金鑰值,並將其傳遞給 IronBarCode.License.LicenseKey 屬性。
using System.Co/nfiguration;
// Retrieve the license key from appSettings in the Web.co/nfig file
string licenseKey = ConfigurationManager.AppSettings["IronBarCode.LicenseKey"];
// Apply the retrieved license key to the IronBarCode LicenseKey property
IronBarCode.License.LicenseKey = licenseKey;
using System.Co/nfiguration;
// Retrieve the license key from appSettings in the Web.co/nfig file
string licenseKey = ConfigurationManager.AppSettings["IronBarCode.LicenseKey"];
// Apply the retrieved license key to the IronBarCode LicenseKey property
IronBarCode.License.LicenseKey = licenseKey;
Imports System.Configuration
' Retrieve the license key from appSettings in the Web.config file
Dim licenseKey As String = ConfigurationManager.AppSettings("IronBarCode.LicenseKey")
' Apply the retrieved license key to the IronBarCode LicenseKey property
IronBarCode.License.LicenseKey = licenseKey
$vbLabelText
$csharpLabel
準備好開始了嗎?
Nuget 下載 2,240,258 | 版本: 2026.5 just released

