Ustawianie klucza licencyjnego w Web.config
This problem has been solved since IronOCR version 2024.3.4.
Exception: Unhandled exception. IronSoftware.Exceptions.LicensingException: IronOCR must be licensed for development.
Dla starszych wersji IronOCR, szczególnie tych pomiędzy wersjami 2023.4.13 i 2024.3.4, występuje znany problem licencjonowania w:
- projektach ASP.NET
- wersjach .NET Framework >= 4.6.2
The key stored in a Web.config file will NOT be picked up and used by the product.
Obejscie problemu
To address this issue, it is recommended to retrieve the license key from the Web.config file using ConfigurationManager in the code, and then apply it to the License.LicenseKey property.
Przykład:
<configuration>
...
<appSettings>
<add key="IronOcr.LicenseKey" value="IRONOCR-MYLICENSE-KEY-1EF01"/>
</appSettings>
...
</configuration>
<configuration>
...
<appSettings>
<add key="IronOcr.LicenseKey" value="IRONOCR-MYLICENSE-KEY-1EF01"/>
</appSettings>
...
</configuration>
Z dostarczonym powyżej plikiem XML możemy użyć ConfigurationManager, aby pobrać wartość klucza licencyjnego i przekazać ją do właściwości IronOcr.License.LicenseKey.
using System.Configuration;
// Retrieve the license key from the Web.config's appSettings
string licenseKey = ConfigurationManager.AppSettings["IronOcr.LicenseKey"];
// Apply the license key to IronOcr to avoid licensing exceptions
IronOcr.License.LicenseKey = licenseKey;
using System.Configuration;
// Retrieve the license key from the Web.config's appSettings
string licenseKey = ConfigurationManager.AppSettings["IronOcr.LicenseKey"];
// Apply the license key to IronOcr to avoid licensing exceptions
IronOcr.License.LicenseKey = licenseKey;
Imports System.Configuration
' Retrieve the license key from the Web.config's appSettings
Private licenseKey As String = ConfigurationManager.AppSettings("IronOcr.LicenseKey")
' Apply the license key to IronOcr to avoid licensing exceptions
IronOcr.License.LicenseKey = licenseKey

