Klucz licencyjny IronWord w konfiguracji ASP.NET
Problem został rozwiązany od wersji IronWord 2024.3.5.
Exception: Unhandled exception. IronSoftware.Exceptions.LicensingException: IronWord must be licensed for development.
Dla starszych wersji IronWord, konkretnie tych wydanych przed wersją 2024.3.5, znany jest problem licencyjny w:
- projektach ASP.NET
- wersjach .NET Framework >= 4.6.2
Klucz przechowywany w pliku Web.config NIE będzie przez produkt wykrywany i używany.
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:
<configuration>
...
<appSettings>
<add key="IronWord.LicenseKey" value="IRONWORD.MYLICENSE.KEY.1EF01"/>
</appSettings>
...
</configuration>
<configuration>
...
<appSettings>
<add key="IronWord.LicenseKey" value="IRONWORD.MYLICENSE.KEY.1EF01"/>
</appSettings>
...
</configuration>
Korzystając z pliku XML dostarczonego powyżej, możemy użyć ConfigurationManager do pobrania wartości klucza licencyjnego i przekazania jej do właściwości IronWord.License.LicenseKey.
// Import the necessary namespace for ConfigurationManager
using System.Configuration;
// Retrieve the license key from the AppSettings in Web.config
string licenseKey = ConfigurationManager.AppSettings["IronWord.LicenseKey"];
// Set the license key for IronWord
IronWord.License.LicenseKey = licenseKey;
// Import the necessary namespace for ConfigurationManager
using System.Configuration;
// Retrieve the license key from the AppSettings in Web.config
string licenseKey = ConfigurationManager.AppSettings["IronWord.LicenseKey"];
// Set the license key for IronWord
IronWord.License.LicenseKey = licenseKey;
' Import the necessary namespace for ConfigurationManager
Imports System.Configuration
' Retrieve the license key from the AppSettings in Web.config
Private licenseKey As String = ConfigurationManager.AppSettings("IronWord.LicenseKey")
' Set the license key for IronWord
IronWord.License.LicenseKey = licenseKey

