Ustawianie klucza licencyjnego w Web.config
Problem ten został rozwiązany od wersji IronOCR 2024.3.4.
Exception: Unhandled exception. IronSoftware.Exceptions.LicensingException: IronOCR must be licensed for development.
Dla starszych wersji IronOCR, konkretnie tych pomiędzy wersjami 2023.4.13 a 2024.3.4, występuje znany problem z licencjonowaniem w:
- projektach ASP.NET
- wersjach .NET Framework >= 4.6.2
Klucz zapisany w pliku Web.config NIE zostanie wykryty i użyty przez produkt.
Obejscie problemu
Aby rozwiązać ten problem, zaleca się pobranie klucza licencyjnego z pliku Web.config przy użyciu ConfigurationManager w kodzie, a następnie zastosowanie go do właściwości License.LicenseKey.
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

