Configuration de la clé de licence du logiciel OCR IronOCR dans Web.config
Ce problème a été résolu depuis la version 2024.3.4 IronOCR .
Exception: Unhandled exception. IronSoftware.Exceptions.LicensingException: IronOCR must be licensed for development.
Pour les anciennes versions d'IronOCR, notamment celles comprises entre les versions 2023.4.13 et 2024.3.4 , il existe un problème de licence connu :
- projets ASP.NET
- version .NET Framework >= 4.6.2
La clé stockée dans un fichier Web.config ne sera PAS récupérée et utilisée par le produit.
Solution de contournement
Pour résoudre ce problème, il est recommandé de récupérer la clé de licence à partir du fichier Web.config en utilisant ConfigurationManager dans le code, puis de l'appliquer à la propriété License.LicenseKey.
Exemple :
<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>
Avec le fichier XML fourni ci-dessus, nous pouvons utiliser ConfigurationManager pour récupérer la valeur de la clé de licence et la transmettre à la propriété 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

