Einrichtung der IronOCR-Lizenz in web.config
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.config-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.config 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.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
- Die Anweisung
using System.Configuration;ermöglicht den Zugriff auf Konfigurationsdateien, wie beispielsweiseWeb.config. ConfigurationManager.AppSettings["IronZip.LicenseKey"]ruft den Lizenzschlüssel ab, der im AbschnittappSettingsvonWeb.configgespeichert 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.

