Konfiguracja licencji IronOCR w pliku web.co/nfig
Problem został rozwiązany w wersji IronZIP 2024.3.3.
Exception: Unhandled exception. IronSoftware.Exceptions.LicensingException: IronZip must be licensed for development.
Exception: Unhandled exception. IronSoftware.Exceptions.LicensingException: IronZip must be licensed for development.
W przypadku starszych wersji IronZip, a konkretnie tych wydanych przed wersją 2024.3.3, 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:
<configuration>
...
<appSettings>
<add key="IronZip.LicenseKey" value="IRONZIP.MYLICENSE.KEY.1EF01"/>
</appSettings>
...
</configuration>
<configuration>
...
<appSettings>
<add key="IronZip.LicenseKey" value="IRONZIP.MYLICENSE.KEY.1EF01"/>
</appSettings>
...
</configuration>
Korzystając z pliku XML podanego powyżej, możemy użyć ConfigurationManager do pobrania wartości klucza licencyjnego i przekazania go do właściwości IronZip.License.LicenseKey.
using System;
using System.Co/nfiguration;
class Program
{
static void Main()
{
// Retrieve the license key from the web.co/nfig appSettings
string licenseKey = ConfigurationManager.AppSettings["IronZip.LicenseKey"];
// Apply the license key to IronZip
IronZip.License.LicenseKey = licenseKey;
// Verify that the license key is set properly
Console.WriteLine("License key applied successfully.");
}
}
using System;
using System.Co/nfiguration;
class Program
{
static void Main()
{
// Retrieve the license key from the web.co/nfig appSettings
string licenseKey = ConfigurationManager.AppSettings["IronZip.LicenseKey"];
// Apply the license key to IronZip
IronZip.License.LicenseKey = licenseKey;
// Verify that the license key is set properly
Console.WriteLine("License key applied successfully.");
}
}
Imports System
Imports System.Configuration
Module Program
Sub Main()
' Retrieve the license key from the web.config appSettings
Dim licenseKey As String = ConfigurationManager.AppSettings("IronZip.LicenseKey")
' Apply the license key to IronZip
IronZip.License.LicenseKey = licenseKey
' Verify that the license key is set properly
Console.WriteLine("License key applied successfully.")
End Sub
End Module
- Dyrektywa
using System.Co/nfiguration;umożliwia dostęp do plików konfiguracyjnych, takich jakWeb.co/nfig. ConfigurationManager.AppSettings["IronZip.LicenseKey"]pobiera klucz licencyjny zapisany w sekcjiappSettingsplikuWeb.co/nfig.IronZip.License.LicenseKey = licenseKey;przypisuje pobrany klucz do biblioteki IronZIP, aby uniknąć wyjątków licencyjnych.- Instrukcja
Console.WriteLine()informuje programistę, że proces ubiegania się o klucz licencyjny zakończył się pomyślnie.

