Einrichtung der IronOCR-Lizenz in web.co/nfig
Das Problem wurde ab IronZip-Version 2024.3.3 behoben.
Exception: Unhandled exception. IronSoftware.Exceptions.LicensingException: IronZip must be licensed for development.
Exception: Unhandled exception. IronSoftware.Exceptions.LicensingException: IronZip must be licensed for development.
Bei älteren IronZip-Versionen, insbesondere solchen, die vor Version 2024.3.3 veröffentlicht wurden, gibt es ein bekanntes Lizenzproblem in:
- ASP.NET-Projekte
- .NET Framework Version >= 4.6.2
Der in einer Web.co/nfig-Datei gespeicherte Schlüssel wird vom Produkt NICHT erfasst und verwendet.
Workaround
Um dieses Problem zu beheben, wird empfohlen, den Lizenzschlüssel mithilfe von ConfigurationManager im Code aus der Datei Web.co/nfig abzurufen und ihn dann auf die Eigenschaft License.LicenseKey anzuwenden.
Beispiel:
<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>
Mit der oben bereitgestellten XML-Datei können wir den ConfigurationManager verwenden, um den Wert des Lizenzschlüssels abzurufen und ihn an die Eigenschaft IronZip.License.LicenseKey zu übergeben.
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
- Die Anweisung
using System.Co/nfiguration;ermöglicht den Zugriff auf Konfigurationsdateien, wie beispielsweiseWeb.co/nfig. ConfigurationManager.AppSettings["IronZip.LicenseKey"]ruft den Lizenzschlüssel ab, der im AbschnittappSettingsvonWeb.co/nfiggespeichert ist.IronZip.License.LicenseKey = licenseKey;weist der IronZIP-Bibliothek den abgerufenen Schlüssel zu, um Lizenzausnahmen zu vermeiden.- Die Anweisung
Console.WriteLine()gibt dem Entwickler die Rückmeldung, dass der Anwendungsprozess für den Lizenzschlüssel erfolgreich abgeschlossen wurde.

