Konfiguracja licencji IronXL w web.config (C#)
Problem został rozwiązany od wersji IronXL 2024.3.20.
Exception: Unhandled exception. IronSoftware.Exceptions.LicensingException: IronXL must be licensed for development.
Dla starszych wersji IronXL, szczególnie tych między wersjami 2023.4.13 a 2024.3.20, istnieje znany problem z licencjonowaniem w:
- projektach ASP.NET
- wersjach .NET Framework >= 4.6.2
Klucz przechowywany w pliku Web.config NIE zostanie wykryty i użyty przez produkt.
Obejście
Aby rozwiązać ten problem, zaleca się pobranie klucza licencyjnego z pliku Web.config 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, jak przechowywać klucz licencyjny w pliku 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>
Dzięki powyższej konfiguracji pliku XML możemy użyć ConfigurationManager do pobrania wartości klucza licencyjnego i ustawienia jej w właściwości 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
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 używane jest ConfigurationManager.AppSettings do pobrania wartości IronXl.LicenseKey z Web.config. Pobrany klucz licencyjny jest następnie ustawiany w IronXl.License.LicenseKey, aby zapewnić prawidłowe funkcjonowanie komponentów IronXL.

