Configurer la licence IronXL dans web.co/nfig (C#)
Le problème a été résolu à partir de la version 2024.3.20 d'IronXL.
Exception: Unhandled exception. IronSoftware.Exceptions.LicensingException: IronXL must be licensed for development.
Pour les anciennes versions d'IronXL, en particulier celles comprises entre les versions 2023.4.13 et 2024.3.20, 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 :
Voici un exemple illustrant comment stocker la clé de licence dans un fichier Web.co/nfig :
<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 l'attribuer à la propriété IronXl.License.LicenseKey :
using System.Co/nfiguration;
// Retrieve the license key from the Web.co/nfig appSettings section
string licenseKey = ConfigurationManager.AppSettings["IronXl.LicenseKey"];
// Apply the retrieved license key to the IronXL component
IronXl.License.LicenseKey = licenseKey;
using System.Co/nfiguration;
// Retrieve the license key from the Web.co/nfig 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
Dim licenseKey As String = ConfigurationManager.AppSettings("IronXl.LicenseKey")
' Apply the retrieved license key to the IronXL component
IronXl.License.LicenseKey = licenseKey
Dans cet exemple, ConfigurationManager.AppSettings est utilisé pour récupérer la valeur de IronXl.LicenseKey à partir de Web.co/nfig. La clé de licence récupérée est ensuite définie sur IronXl.License.LicenseKey afin de garantir le bon fonctionnement des composants IronXL.

