Ustawianie klucza licencyjnego w Web.config
Ten problem został rozwiązany od wersji IronPDF 2024.3.3.
Exception: Unhandled exception. IronSoftware.Exceptions.LicensingException: IronPDF must be licensed for development.
Dla starszych wersji IronPdf, zwłaszcza tych między 2023.4.4 a 2024.3.3, występuje znany problem z licencjonowaniem w:
- projektach ASP.NET
- wersjach .NET Framework >= 4.6.2
Klucz przechowywany w pliku Web.config NIE zostanie pobrany i użyty przez produkt.
Obejście problemu
Aby rozwiązać ten problem, zaleca się pobranie klucza licencyjnego z pliku Web.config przy użyciu ConfigurationManager w kodzie, a następnie zastosowanie go do właściwości License.LicenseKey.
Przykład:
<configuration>
...
<appSettings>
<add key="IronPdf.LicenseKey" value="IRONPDF-MYLICENSE-KEY-1EF01"/>
</appSettings>
...
</configuration>
<configuration>
...
<appSettings>
<add key="IronPdf.LicenseKey" value="IRONPDF-MYLICENSE-KEY-1EF01"/>
</appSettings>
...
</configuration>
Dzięki dostarczonemu powyżej plikowi XML możemy użyć ConfigurationManager do pobrania wartości klucza licencyjnego i przekazania go do właściwości IronPdf.License.LicenseKey.
using System.Configuration;
class Program
{
static void Main()
{
// Retrieve the license key from the Web.config file
string licenseKey = ConfigurationManager.AppSettings["IronPdf.LicenseKey"];
// Apply the license key to the IronPdf library
IronPdf.License.LicenseKey = licenseKey;
// Additional processing can continue here
}
}
using System.Configuration;
class Program
{
static void Main()
{
// Retrieve the license key from the Web.config file
string licenseKey = ConfigurationManager.AppSettings["IronPdf.LicenseKey"];
// Apply the license key to the IronPdf library
IronPdf.License.LicenseKey = licenseKey;
// Additional processing can continue here
}
}
Imports System.Configuration
Friend Class Program
Shared Sub Main()
' Retrieve the license key from the Web.config file
Dim licenseKey As String = ConfigurationManager.AppSettings("IronPdf.LicenseKey")
' Apply the license key to the IronPdf library
IronPdf.License.LicenseKey = licenseKey
' Additional processing can continue here
End Sub
End Class

