Konfiguracja licencji IronOCR w web.config
Problem został rozwiązany od 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 starszych wersjach IronZip, szczególnie wydanych przed wersją 2024.3.3, istnieje znany problem z licencjonowaniem w:
- projektach ASP.NET
- wersjach .NET Framework >= 4.6.2
Klucz zapisany w pliku Web.config NIE zostanie wykryty i użyty przez produkt.
Obejście
Aby rozwiązać ten problem, zaleca się pobranie klucza licencji z pliku Web.config przy użyciu ConfigurationManager w kodzie i przypisanie 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>
Za pomocą załączonego powyżej pliku XML możemy użyć ConfigurationManager, aby pobrać wartość klucza licencji i przekazać ją do właściwości IronZip.License.LicenseKey.
using System;
using System.Configuration;
class Program
{
static void Main()
{
// Retrieve the license key from the web.config 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.Configuration;
class Program
{
static void Main()
{
// Retrieve the license key from the web.config 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
Friend Class Program
Shared 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 Class
- Dyrektywa
using System.Configuration;umożliwia dostęp do plików konfiguracyjnych, takich jakWeb.config. ConfigurationManager.AppSettings["IronZip.LicenseKey"]pobiera klucz licencji zapisany w sekcjiappSettingswWeb.config.IronZip.License.LicenseKey = licenseKey;przypisuje pobrany klucz do biblioteki IronZip, aby uniknąć wyjątków związanych z licencjonowaniem.- Oświadczenie
Console.WriteLine()dostarcza programiście informacji zwrotnej, że proces aplikacji klucza licencji zakończono pomyślnie.

