web.config で IronXL ライセンスを構成する (C#)

This article was translated from English: Does it need improvement?
Translated
View the article in English

問題は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を使用して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

上記の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
$vbLabelText   $csharpLabel

この例では、IronXL.LicenseKeyの値を取得します。 取得されたライセンスキーは、IronXLコンポーネントが正常に機能するようにするためにIronXL.License.LicenseKeyに設定されます。

Curtis Chau
テクニカルライター

Curtis Chauは、カールトン大学でコンピュータサイエンスの学士号を取得し、Node.js、TypeScript、JavaScript、およびReactに精通したフロントエンド開発を専門としています。直感的で美しいユーザーインターフェースを作成することに情熱を持ち、Curtisは現代のフレームワークを用いた開発や、構造の良い視覚的に魅力的なマニュアルの作成を楽しんでいます。

開発以外にも、CurtisはIoT(Internet of Things)への強い関心を持ち、ハードウェアとソフトウェアの統合方法を模索しています。余暇には、ゲームをしたりDiscordボットを作成したりして、技術に対する愛情と創造性を組み合わせています。

準備はできましたか?
Nuget ダウンロード 2,150,290 | バージョン: 2026.7 リリースされたばかり
Still Scrolling Icon

まだスクロールしていますか?

すぐに証拠が欲しいですか? PM > Install-Package IronXL.Excel
サンプルを実行する あなたのデータがスプレッドシートになるのを見る。