web.co/nfig における IronOCR のライセンス設定
この問題は、IronZip バージョン 2024.3.3 にて解決されました。
Exception: Unhandled exception. IronSoftware.Exceptions.LicensingException: IronZip must be licensed for development.
Exception: Unhandled exception. IronSoftware.Exceptions.LicensingException: IronZip must be licensed for development.
IronZipの旧バージョン、具体的にはバージョン2024.3.3より前にリリースされたものについては、以下の点で既知のライセンス上の問題があります:
- ASP.NET プロジェクト
- .NET Framework バージョン 4.6.2 以上
Web.co/nfig ファイルに保存されたキーは、本製品によって取得・使用されることはありません。
回避策
この問題に対処するには、コード内でConfigurationManagerを使用してWeb.co/nfigファイルからライセンスキーを取得し、それをLicense.LicenseKeyプロパティに適用することを推奨します。
例:
<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>
上記のXMLファイルを使用すれば、ConfigurationManagerを利用してライセンスキーの値を取得し、それをIronZip.License.LicenseKeyプロパティに渡すことができます。
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
using System.Co/nfiguration;ディレクティブを使用すると、Web.co/nfigなどの設定ファイルにアクセスできます。ConfigurationManager.AppSettings["IronZip.LicenseKey"]は、appSettingsセクションに格納されているライセンスキーをWeb.co/nfigから取得します。IronZip.License.LicenseKey = licenseKey;は、ライセンスに関する例外を回避するために、取得したキーを IronZIPライブラリに割り当てます。Console.WriteLine()ステートメントは、ライセンスキーの申請プロセスが正常に完了したことを開発者に通知します。

