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
Klucz przechowywany w pliku Web.config nie zostanie podjęty ani użyty przez produkt.
Obejscie problemu
Aby rozwiązać ten problem, zaleca się pobranie klucza licencyjnego z pliku Web.config, używając ConfigurationManager w kodzie, a następnie zastosowanie go w 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

