Konfigurieren der IronXL-Lizenz in web.co/nfig (C#)
Das Problem wurde mit der IronXL-Version 2024.3.20 behoben.
Exception: Unhandled exception. IronSoftware.Exceptions.LicensingException: IronXL must be licensed for development.
Bei älteren IronXL-Versionen, insbesondere den Versionen zwischen 2023.4.13 und 2024.3.20, gibt es ein bekanntes Lizenzproblem in:
- ASP.NET-Projekte
- .NET Framework Version >= 4.6.2
Der in einer Web.co/nfig-Datei gespeicherte Schlüssel wird vom Produkt NICHT erfasst und verwendet.
Workaround
Um dieses Problem zu beheben, wird empfohlen, den Lizenzschlüssel mithilfe von ConfigurationManager im Code aus der Datei Web.co/nfig abzurufen und ihn dann auf die Eigenschaft License.LicenseKey anzuwenden.
Beispiel:
Nachfolgend finden Sie ein Beispiel dafür, wie der Lizenzschlüssel in einer Web.co/nfig-Datei gespeichert wird:
<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>
Mit der oben genannten XML-Dateikonfiguration können wir den ConfigurationManager verwenden, um den Wert des Lizenzschlüssels abzurufen und ihn der Eigenschaft IronXl.License.LicenseKey zuzuweisen:
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
In diesem Beispiel wird ConfigurationManager.AppSettings verwendet, um den Wert von IronXl.LicenseKey aus Web.co/nfig abzurufen. Der abgerufene Lizenzschlüssel wird dann auf IronXl.License.LicenseKey gesetzt, um sicherzustellen, dass die IronXL-Komponenten ordnungsgemäß funktionieren.

