Setting License Key in Web.config

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

<i class="fa-regular fa-circle-check" style="color: この問題はIronOCRのバージョン2024.3.4から解決済みです。

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プロジェクト
  • .NET Frameworkバージョン >= 4.6.2.

Web.configファイルに格納されたキーは、製品によって拾われ使用されることはありません。

回避策

この問題に対処するには、コード内で ConfigurationManager を使用して Web.config<//code> ファイルからライセンス キーを取得し、それを License.LicenseKey プロパティに適用することをお勧めします。

例:

<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

上記のXMLファイルを用いて、ConfigurationManagerでライセンスキーの値を取得し、IronOcr.License.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;
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
テクニカルライター

Curtis Chauは、カールトン大学でコンピュータサイエンスの学士号を取得し、Node.js、TypeScript、JavaScript、およびReactに精通したフロントエンド開発を専門としています。直感的で美しいユーザーインターフェースを作成することに情熱を持ち、Curtisは現代のフレームワークを用いた開発や、構造の良い視覚的に魅力的なマニュアルの作成を楽しんでいます。

開発以外にも、CurtisはIoT(Internet of Things)への強い関心を持ち、ハードウェアとソフトウェアの統合方法を模索しています。余暇には、ゲームをしたりDiscordボットを作成したりして、技術に対する愛情と創造性を組み合わせています。

準備はいいですか?
Nuget ダウンロード 5,044,537 | バージョン: 2025.11 ただ今リリースされました