IronOCR(OCRソフト)のライセンスキーをWeb.configで設定する方法
この問題はIronOCRバージョン2024.3.4以降で解決されています。
Exception: Unhandled exception. IronSoftware.Exceptions.LicensingException: IronOCR must be licensed for development.
古い IronOCR バージョン、具体的にはバージョン2023.4.13から2024.3.4までのバージョンでは、次のライセンスに関する既知の問題があります。
- ASP.NETプロジェクト
- .NET Frameworkバージョン >= 4.6.2
Web.config ファイルに保存されたキーは、製品によって取得および使用されません。
回避策
この問題に対処するには、コード内でConfigurationManagerを使用して Web.config ファイルからライセンス キーを取得し、それを 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 ファイルを使用すると、 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

