Configurer la licence IronXL dans web.config (C#)
The problem has been resolved as of IronXL version 2024.3.20.
Exception: Unhandled exception. IronSoftware.Exceptions.LicensingException: IronXL must be licensed for development.
Pour les anciennes versions d'IronXL, notamment celles comprises entre les versions 2023.4.13 et 2024.3.20 , 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 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 :
Voici un exemple de stockage de la clé de licence dans un fichier Web.config :
<configuration>
...
<appSettings>
<add key="IronXL.LicenseKey" value="IronXL-MYLICENSE-KEY-1EF01"/>
</appSettings>
...
</configuration>
<configuration>
...
<appSettings>
<add key="IronXL.LicenseKey" value="IronXL-MYLICENSE-KEY-1EF01"/>
</appSettings>
...
</configuration>
Avec la configuration du fichier XML ci-dessus, nous pouvons utiliser ConfigurationManager pour récupérer la valeur de la clé de licence et la définir sur la propriété IronXL.License.LicenseKey :
using System.Configuration;
// Retrieve the license key from the Web.config appSettings section
string licenseKey = ConfigurationManager.AppSettings["IronXL.LicenseKey"];
// Apply the retrieved license key to the IronXL component
IronXL.License.LicenseKey = licenseKey;
using System.Configuration;
// Retrieve the license key from the Web.config appSettings section
string licenseKey = ConfigurationManager.AppSettings["IronXL.LicenseKey"];
// Apply the retrieved license key to the IronXL component
IronXL.License.LicenseKey = licenseKey;
Imports System.Configuration
' Retrieve the license key from the Web.config appSettings section
Private licenseKey As String = ConfigurationManager.AppSettings("IronXL.LicenseKey")
' Apply the retrieved license key to the IronXL component
IronXL.License.LicenseKey = licenseKey
Dans cet exemple, le ConfigurationManager.AppSettings est utilisé pour récupérer la valeur de IronXL.LicenseKey à partir de Web.config. La clé de licence récupérée est ensuite définie sur le IronXL.License.LicenseKey pour garantir que les composants IronXL fonctionnent correctement.

