web.co/nfig での IronXL ライセンスの設定 (C#)
この問題は、IronXL バージョン 2024.3.20 にて解決されました。
Exception: Unhandled exception. IronSoftware.Exceptions.LicensingException: IronXL must be licensed for development.
古いバージョンのIronXL、具体的にはバージョン2023.4.13から2024.3.20までの間において、以下の点で既知のライセンス上の問題があります:
- ASP.NET プロジェクト
- .NET Framework バージョン 4.6.2 以上
Web.co/nfig ファイルに保存されたキーは、本製品によって取得・使用されることはありません。
回避策
この問題に対処するには、コード内でConfigurationManagerを使用してLicense.LicenseKeyプロパティに適用することを推奨します。
例:
以下は、Web.co/nfigファイルにライセンスキーを保存する方法の例です:
<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.Co/nfiguration;
// Retrieve the license key from the Web.co/nfig appSettings section
string licenseKey = ConfigurationManager.AppSettings["IronXl.LicenseKey"];
// Apply the retrieved license key to the IronXL component
IronXl.License.LicenseKey = licenseKey;
using System.Co/nfiguration;
// Retrieve the license key from the Web.co/nfig 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
Dim licenseKey As String = ConfigurationManager.AppSettings("IronXl.LicenseKey")
' Apply the retrieved license key to the IronXL component
IronXl.License.LicenseKey = licenseKey
この例では、ConfigurationManager.AppSettings を使用して、Web.co/nfig から IronXl.LicenseKey の値を取得しています。 取得したライセンスキーは、IronXLコンポーネントが正常に機能するように、IronXl.License.LicenseKeyに設定されます。

