Configure IronXL License in web.config (C#)

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

The problem has been resolved as of IronXL version 2024.3.20.

Exception: Unhandled exception. IronSoftware.Exceptions.LicensingException: IronXL must be licensed for development.

For older IronXL versions, specifically those between versions 2023.4.13 and 2024.3.20, there is a known licensing issue in:

  • ASP.NET projects
  • .NET Framework version >= 4.6.2

The key stored in a Web.config file will NOT be picked up and used by the product.

Workaround

To address this issue, it is recommended to retrieve the license key from the Web.config file using ConfigurationManager in the code, and then apply it to the License.LicenseKey property.

Example:

Below is an example of how to store the license key in a Web.config file:

<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

With the above XML file setup, we can use ConfigurationManager to retrieve the license key value and set it to the IronXL.License.LicenseKey property:

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

In this example, the ConfigurationManager.AppSettings is used to retrieve the value of IronXL.LicenseKey from Web.config. The retrieved license key is then set to the IronXL.License.LicenseKey to ensure that the IronXL components can function properly.

Curtis Chau
技术作家

Curtis Chau 拥有卡尔顿大学的计算机科学学士学位,专注于前端开发,精通 Node.js、TypeScript、JavaScript 和 React。他热衷于打造直观且美观的用户界面,喜欢使用现代框架并创建结构良好、视觉吸引力强的手册。

除了开发之外,Curtis 对物联网 (IoT) 有浓厚的兴趣,探索将硬件和软件集成的新方法。在空闲时间,他喜欢玩游戏和构建 Discord 机器人,将他对技术的热爱与创造力相结合。

准备开始了吗?
Nuget 下载 1,686,155 | 版本: 2025.11 刚刚发布