web.config での 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.config ファイルに保存されたキーは、製品によって取得および使用されません。
回避策
この問題に対処するには、コード内でConfigurationManagerを使用して Web.config ファイルからライセンス キーを取得し、それを 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.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
using System.Configuration;ディレクティブは、Web.configなどの構成ファイルへのアクセスを許可します。ConfigurationManager.AppSettings["IronZip.LicenseKey"]は、Web.configのappSettingsセクションに保存されているライセンス キーを取得します。IronZip.License.LicenseKey = licenseKey;は、ライセンス例外を回避するために、取得したキーをIronZIPライブラリに割り当てます。Console.WriteLine()ステートメントは、ライセンス キーの適用プロセスが正常に完了したことを開発者にフィードバックします。

