Rozwiązywanie problemów z konfiguracją licencji IronPrint
Ten problem został rozwiązany w najnowszych wersjach IronPrint.
# This shell output shows an unhandled exception error due to missing license for IronPrint.
Exception: Unhandled exception. IronSoftware.Exceptions.LicensingException: IronPrint must be licensed for development.
Dla starszych wersji IronPrint 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 przy użyciu ConfigurationManager w kodzie, a następnie zastosowanie go do właściwości License.LicenseKey.
Przykład:
<configuration>
...
<appSettings>
<add key="IronPrint.LicenseKey" value="IRONPRINT.MYLICENSE.KEY.1EF01"/>
</appSettings>
...
</configuration>
Za pomocą dostarczonego powyżej pliku XML możemy użyć ConfigurationManager do pobrania wartości klucza licencyjnego i przekazania jej do właściwości IronPrint.License.LicenseKey.
using System;
using System.Configuration;
namespace IronPrintLicenseSetup
{
class Program
{
static void Main()
{
// Retrieve the license key from the appSettings section of the Web.config file.
string licenseKey = ConfigurationManager.AppSettings["IronPrint.LicenseKey"];
// Apply the retrieved license key to the IronPrint's LicenseKey property.
IronPrint.License.LicenseKey = licenseKey;
// Notify user that the license key has been applied.
Console.WriteLine("License Key has been applied successfully.");
}
}
}Imports System
Imports System.Configuration
Namespace IronPrintLicenseSetup
Friend Class Program
Shared Sub Main()
' Retrieve the license key from the appSettings section of the Web.config file.
Dim licenseKey As String = ConfigurationManager.AppSettings("IronPrint.LicenseKey")
' Apply the retrieved license key to the IronPrint's LicenseKey property.
IronPrint.License.LicenseKey = licenseKey
' Notify user that the license key has been applied.
Console.WriteLine("License Key has been applied successfully.")
End Sub
End Class
End NamespaceImports System
Imports System.Configuration
Namespace IronPrintLicenseSetup
Friend Class Program
Shared Sub Main()
' Retrieve the license key from the appSettings section of the Web.config file.
Dim licenseKey As String = ConfigurationManager.AppSettings("IronPrint.LicenseKey")
' Apply the retrieved license key to the IronPrint's LicenseKey property.
IronPrint.License.LicenseKey = licenseKey
' Notify user that the license key has been applied.
Console.WriteLine("License Key has been applied successfully.")
End Sub
End Class
End NamespaceW powyższym przykładzie ConfigurationManager.AppSettings jest używany do pobrania klucza licencyjnego bezpośrednio z Web.config. Klucz jest następnie ustawiony jako LicenseKey dla komponentu IronPrint, co zapewnia, że aplikacja posiada niezbędną licencję do poprawnego działania.
Curtis Chau posiada tytuł licencjata z informatyki (Uniwersytet Carleton) i specjalizuje się w front-endowym rozwoju, z ekspertką w Node.js, TypeScript, JavaScript i React. Pasjonuje się tworzeniem intuicyjnych i estetycznie przyjemnych interfejsów użytkownika, Curtis cieszy się pracą z nowoczesnymi frameworkami i tworzeniem dobrze zorganizowanych, atrakcyjnych wizualnie podręczników.