Lizenzschlüssel in Web.config festlegen – IronOCR OCR Software korrekt lizenzieren
Dieses Problem wurde mit IronOCR Version 2024.3.4 behoben .
Exception: Unhandled exception. IronSoftware.Exceptions.LicensingException: IronOCR must be licensed for development.
Für ältere IronOCR-Versionen, insbesondere diejenigen zwischen den Versionen 2023.4.13 und 2024.3.4, gibt es ein bekanntes Lizenzproblem bei:
- ASP.NET-Projekten
- .NET Framework Version >= 4.6.2
Der in einer Web.config Datei gespeicherte Schlüssel wird vom Produkt NICHT erkannt und verwendet.
Workaround
Um dieses Problem zu beheben, wird empfohlen, den Lizenzschlüssel aus der Datei Web.config mithilfe des ConfigurationManager im Code abzurufen und ihn dann auf die Eigenschaft License.LicenseKey anzuwenden.
Beispiel:
<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>
Mit der oben bereitgestellten XML-Datei können wir ConfigurationManager verwenden, um den Lizenzschlüsselwert abzurufen und an die IronOcr.License.LicenseKey-Eigenschaft zu übergeben.
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

