Définition de la clé de licence dans Web.co/nfig
Ce problème a été résolu depuis la version 2024.3.4 d'IronOCR.
Exception: Unhandled exception. IronSoftware.Exceptions.LicensingException: IronOCR must be licensed for development.
Pour les anciennes versions d'IronOCR, en particulier celles comprises entre les versions 2023.4.13 et 2024.3.4, il existe un problème de licence connu dans :
- Projets ASP.NET
- .NET Framework version >= 4.6.2
La clé stockée dans un fichier Web.co/nfig ne sera PAS récupérée ni 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.co/nfig à l'aide de 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>
À l'aide du 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.Co/nfiguration;
// Retrieve the license key from the Web.co/nfig's appSettings
string licenseKey = ConfigurationManager.AppSettings["IronOcr.LicenseKey"];
// Apply the license key to IronOcr to avoid licensing exceptions
IronOcr.License.LicenseKey = licenseKey;
using System.Co/nfiguration;
// Retrieve the license key from the Web.co/nfig'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
Dim licenseKey As String = ConfigurationManager.AppSettings("IronOcr.LicenseKey")
' Apply the license key to IronOcr to avoid licensing exceptions
IronOcr.License.LicenseKey = licenseKey

