Konfiguracja licencji IronXL w pliku web.co/nfig (C#)
Problem został rozwiązany w wersji IronXL 2024.3.20.
Exception: Unhandled exception. IronSoftware.Exceptions.LicensingException: IronXL must be licensed for development.
W przypadku starszych wersji IronXL, a konkretnie tych między wersjami 2023.4.13 a 2024.3.20, występuje znany problem z licencjonowaniem w:
- Projekty ASP.NET
- .NET Framework w wersji >= 4.6.2
Klucz zapisany w pliku Web.co/nfig NIE zostanie pobrany i wykorzystany przez produkt.
Rozwiązanie
Aby rozwiązać ten problem, zaleca się pobranie klucza licencyjnego z pliku Web.co/nfig za pomocą ConfigurationManager w kodzie, a następnie zastosowanie go do właściwości License.LicenseKey.
Przykład:
Poniżej znajduje się przykład przechowywania klucza licencyjnego w pliku 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>
Dzięki powyższej konfiguracji pliku XML możemy użyć ConfigurationManager do pobrania wartości klucza licencyjnego i ustawienia go jako właściwości 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
W tym przykładzie ConfigurationManager.AppSettings służy do pobrania wartości IronXl.LicenseKey z Web.co/nfig. Pobierany klucz licencyjny jest następnie ustawiany na IronXl.License.LicenseKey, aby zapewnić prawidłowe działanie komponentów IronXL.

