Setting License Key in Web.config

This article was translated from English: Does it need improvement?
Translated
View the article in English

Dieses Problem wurde seit der IronOCR-Version 2024.3.4 gelöst.

Exception: Unhandled exception. IronSoftware.Exceptions.LicensingException: IronOCR must be licensed for development.

For older IronOcr versions, specifically those between versions 2023.4.13 and 2024.3.4, there is a known licensing issue in:

  • ASP.NET-Projekten
  • .NET Framework Version >= 4.6.2

Der im Web.config-Datei gespeicherte Schlüssel wird vom Produkt NICHT erkannt und verwendet.

Workaround

Um dieses Problem zu beheben, wird empfohlen, den Lizenzschlüssel aus der Web.config-Datei mit ConfigurationManager im Code abzurufen und ihn dann auf die License.LicenseKey-Eigenschaft anzuwenden.

Beispiel:

<configuration>
  ...
  <appSettings>
    <add key="IronOcr.LicenseKey" value="IRONOCR-MYLICENSE-KEY-1EF01"/>
  </appSettings>
  ...
</configuration>
<configuration>
  ...
  <appSettings>
    <add key="IronOcr.LicenseKey" value="IRONOCR-MYLICENSE-KEY-1EF01"/>
  </appSettings>
  ...
</configuration>
XML

Mit der oben bereitgestellten XML-Datei können wir ConfigurationManager verwenden, um den Lizenzschlüsselwert abzurufen und an die IronOcr.License.LicenseKey-Eigenschaft zu übergeben.

using System.Configuration;

// Retrieve the license key from the Web.config's appSettings
string licenseKey = ConfigurationManager.AppSettings["IronOcr.LicenseKey"];

// Apply the license key to IronOcr to avoid licensing exceptions
IronOcr.License.LicenseKey = licenseKey;
using System.Configuration;

// Retrieve the license key from the Web.config's appSettings
string licenseKey = ConfigurationManager.AppSettings["IronOcr.LicenseKey"];

// Apply the license key to IronOcr to avoid licensing exceptions
IronOcr.License.LicenseKey = licenseKey;
Imports System.Configuration

' Retrieve the license key from the Web.config's appSettings
Private licenseKey As String = ConfigurationManager.AppSettings("IronOcr.LicenseKey")

' Apply the license key to IronOcr to avoid licensing exceptions
IronOcr.License.LicenseKey = licenseKey
$vbLabelText   $csharpLabel
Curtis Chau
Technischer Autor

Curtis Chau hat einen Bachelor-Abschluss in Informatik von der Carleton University und ist spezialisiert auf Frontend-Entwicklung mit Expertise in Node.js, TypeScript, JavaScript und React. Leidenschaftlich widmet er sich der Erstellung intuitiver und ästhetisch ansprechender Benutzerschnittstellen und arbeitet gerne mit modernen Frameworks sowie der Erstellung gut strukturierter, optisch ansprechender ...

Weiterlesen
Bereit anzufangen?
Nuget Downloads 5,044,537 | Version: 2025.11 gerade veröffentlicht