Web.configでIronXLライセンスを設定する (C#): xlsxファイル対応 Excel操作 C# ライセンスガイド
<i class="fa-regular fa-circle-check"@--STYLE-ATTR-84--@@> この問題はIronXLバージョン2024.3.20で解決済みです。
Exception: Unhandled exception. IronSoftware.Exceptions.LicensingException: IronXL must be licensed for development.
2023.4.13 から 2024.3.20 までのバージョンの、古い IronXL のバージョンでライセンスの問題が知られています:
- ASP.NETプロジェクト
- .NET Frameworkバージョン >= 4.6.2
Web.configファイルに保存されたキーが製品によって使用されません。
回避策
この問題を解決するには、コード内でConfigurationManagerを使用してWeb.configファイルからライセンスキーを取得し、それをLicense.LicenseKeyプロパティに適用することをお勧めします。
例:
以下はWeb.configファイルにライセンスキーを保存する方法の例です:
<configuration>
...
<appSettings>
<add key="IronXL.LicenseKey" value="IronXL-MYLICENSE-KEY-1EF01"/>
</appSettings>
...
</configuration>
<configuration>
...
<appSettings>
<add key="IronXL.LicenseKey" value="IronXL-MYLICENSE-KEY-1EF01"/>
</appSettings>
...
</configuration>
上記の XML ファイル設定により、ConfigurationManager を使用してライセンスキーバリューを取得し、それを IronXL.License.LicenseKey プロパティに設定できます:
using System.Configuration;
// Retrieve the license key from the Web.config appSettings section
string licenseKey = ConfigurationManager.AppSettings["IronXL.LicenseKey"];
// Apply the retrieved license key to the IronXL component
IronXL.License.LicenseKey = licenseKey;
using System.Configuration;
// Retrieve the license key from the Web.config appSettings section
string licenseKey = ConfigurationManager.AppSettings["IronXL.LicenseKey"];
// Apply the retrieved license key to the IronXL component
IronXL.License.LicenseKey = licenseKey;
Imports System.Configuration
' Retrieve the license key from the Web.config appSettings section
Private licenseKey As String = ConfigurationManager.AppSettings("IronXL.LicenseKey")
' Apply the retrieved license key to the IronXL component
IronXL.License.LicenseKey = licenseKey
この例では、ConfigurationManager.AppSettings を使用して Web.config から IronXL.LicenseKey の値を取得します。 取得したライセンスキーは IronXL.License.LicenseKey に設定され、IronXL コンポーネントが正常に機能することを保証します。

